Class Liste<T>
java.lang.Object
fr.formiko.usuel.structures.listes.Liste<T>
- All Implemented Interfaces:
Serializable
,Iterable<T>
,Collection<T>
,List<T>
- Direct Known Subclasses:
GBlade
,GCreature
,GEspece
,GEtiquetteJoueur
,GGInt
,GGraine
,GIEspece
,GIndividu
,GInsecte
,GInt
,GJoueur
,GMessage
,GString
Custom Linked Liste class using Generics.
- Author:
- Hydrolien
- See Also:
- Serialized Form
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
boolean
add new Element at the default place. At the tail of the linked listboolean
addAll(int index, Collection<? extends T> c)
boolean
addAll(Collection<? extends T> c)
void
add new Element at head of the linked listvoid
Add an other linked list at tail of the linked list.boolean
addSorted(T t, Comparator<? super T> c)
void
add new Element at tail of the linked listvoid
clear()
boolean
Return true if this contains T content.boolean
containsAll(Collection<?> c)
boolean
Standard equals function.Return a new Liste with only item that match with predicate.get(int index)
return the xa itemgetFirst()
getHead()
getItem(int index)
getLast()
getMost(Comparator<? super T> c)
getTail()
int
boolean
isEmpty()
Return true is list is empty.iterator()
return the coresponding Iteratorint
lastIndexOf(Object o)
int
length()
listIterator(int index)
pop()
Pop (return the item & remove it) of the top of the heap (at Head).void
Push at the top of the heap list as Head.void
Push at the top of the heap (at head).private void
readObject(ObjectInputStream stream)
Load Serializable list with a iterative implementation.remove(int i)
Delete the xa elementboolean
Delete the 1a t elementboolean
removeAll(Collection<?> c)
boolean
copy only different item.boolean
removeItem(int i)
Delete the xa elementprivate boolean
removeItemBeforeUpdateTail(int i)
Private function to remove itemboolean
retainAll(Collection<?> c)
protected void
protected void
int
size()
Return the number of element.void
sort(Comparator<? super T> c)
subList(int a, int b)
Object[]
toArray()
<T> T[]
toArray(T[] a)
Return this as a GString.toString()
Return a long string with all the list value split by ' '.Return a long string with all the list value split by '\n'.void
Update tail element.private void
writeObject(ObjectOutputStream stream)
Save Serializable list with a iterative implementation.Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.List
hashCode, replaceAll, spliterator
-
Field Details
-
head
-
tail
-
-
Constructor Details
-
Liste
public Liste()
-
-
Method Details
-
getHead
-
setHead
-
getTail
-
setTail
-
getFirst
-
getLast
-
addTail
add new Element at tail of the linked list
content content of the element to add. -
addHead
add new Element at head of the linked list
content content of the element to add. -
updateTail
public void updateTail()Update tail element. -
add
add new Element at the default place. At the tail of the linked list -
add
-
addList
Add an other linked list at tail of the linked list. -
add
-
push
Push at the top of the heap (at head). -
push
Push at the top of the heap list as Head. -
pop
Pop (return the item & remove it) of the top of the heap (at Head). -
isEmpty
public boolean isEmpty()Return true is list is empty.
It's a better function than doing list.length()==0. -
size
public int size()Return the number of element. -
length
public int length() -
equals
Standard equals function. Null & other class type proof. -
contains
Return true if this contains T content. -
toString
Return a long string with all the list value split by ' '. -
toStringId
-
toGString
Return this as a GString. -
toStringLong
Return a long string with all the list value split by '\n'. -
filter
Return a new Liste with only item that match with predicate.- Parameters:
predicate
- a predicate that is used for the filter- Returns:
- a new Liste&lb;T&rb; filtered
-
get
return the xa item -
getItem
-
removeDuplicateItem
public boolean removeDuplicateItem()copy only different item. -
removeItem
public boolean removeItem(int i)Delete the xa element- Parameters:
i
- the number of the element to remove.- Returns:
- true if it have been remove
-
removeItemBeforeUpdateTail
private boolean removeItemBeforeUpdateTail(int i)Private function to remove item- Parameters:
i
- the number of the element to remove.- Returns:
- true if it have been remove
-
remove
Delete the xa element -
remove
Delete the 1a t element -
subList
-
listIterator
- Specified by:
listIterator
in interfaceList<T>
-
listIterator
- Specified by:
listIterator
in interfaceList<T>
-
indexOf
-
lastIndexOf
- Specified by:
lastIndexOf
in interfaceList<T>
-
set
-
retainAll
-
containsAll
- Specified by:
containsAll
in interfaceCollection<T>
- Specified by:
containsAll
in interfaceList<T>
-
toArray
public <T> T[] toArray(T[] a) -
toArray
-
addAll
-
addAll
-
removeAll
-
clear
public void clear() -
getMost
-
sort
-
addSorted
-
iterator
return the coresponding Iterator -
writeObject
Save Serializable list with a iterative implementation.
This is used to avoid save issues with big saves.- Throws:
IOException
-
readObject
Load Serializable list with a iterative implementation.
This is used to avoid save issues with big saves.- Throws:
IOException
ClassNotFoundException
-