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

public class Liste<T> extends Object implements Iterable<T>, Serializable, List<T>
Custom Linked Liste class using Generics.
Author:
Hydrolien
See Also:
Serialized Form
  • Field Details

  • Constructor Details

    • Liste

      public Liste()
  • Method Details

    • getHead

      public ListeNode<T> getHead()
    • setHead

      protected void setHead(ListeNode<T> node)
    • getTail

      public ListeNode<T> getTail()
    • setTail

      protected void setTail(ListeNode<T> node)
    • getFirst

      public T getFirst()
    • getLast

      public T getLast()
    • addTail

      public void addTail(T content)
      add new Element at tail of the linked list
      content content of the element to add.
    • addHead

      public void addHead(T content)
      add new Element at head of the linked list
      content content of the element to add.
    • updateTail

      public void updateTail()
      Update tail element.
    • add

      public boolean add(T content)
      add new Element at the default place. At the tail of the linked list
      Specified by:
      add in interface Collection<T>
      Specified by:
      add in interface List<T>
    • add

      public void add(int index, T content)
      Specified by:
      add in interface List<T>
    • addList

      public void addList(Liste<T> list)
      Add an other linked list at tail of the linked list.
    • add

      public void add(Liste<T> list)
    • push

      public void push(T t)
      Push at the top of the heap (at head).
    • push

      public void push(Liste<T> list)
      Push at the top of the heap list as Head.
    • pop

      public T 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.
      Specified by:
      isEmpty in interface Collection<T>
      Specified by:
      isEmpty in interface List<T>
    • size

      public int size()
      Return the number of element.
      Specified by:
      size in interface Collection<T>
      Specified by:
      size in interface List<T>
    • length

      public int length()
    • equals

      public boolean equals(Object o)
      Standard equals function. Null & other class type proof.
      Specified by:
      equals in interface Collection<T>
      Specified by:
      equals in interface List<T>
      Overrides:
      equals in class Object
      Parameters:
      o - o is the Object to test. It can be null or something else than this class.
    • contains

      public boolean contains(Object o)
      Return true if this contains T content.
      Specified by:
      contains in interface Collection<T>
      Specified by:
      contains in interface List<T>
    • toString

      public String toString()
      Return a long string with all the list value split by ' '.
      Overrides:
      toString in class Object
    • toStringId

      public String toStringId()
    • toGString

      public GString toGString()
      Return this as a GString.
    • toStringLong

      public String toStringLong()
      Return a long string with all the list value split by '\n'.
    • filter

      public Liste<T> filter(Predicate<T> predicate)
      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

      public T get(int index)
      return the xa item
      Specified by:
      get in interface List<T>
    • getItem

      public T getItem(int index)
    • 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

      public T remove(int i)
      Delete the xa element
      Specified by:
      remove in interface List<T>
      Parameters:
      i - the number of the element to remove.
    • remove

      public boolean remove(Object o)
      Delete the 1a t element
      Specified by:
      remove in interface Collection<T>
      Specified by:
      remove in interface List<T>
      Parameters:
      o - the element to remove.
      Returns:
      true if it have been remove
    • subList

      public Liste<T> subList(int a, int b)
      Specified by:
      subList in interface List<T>
    • listIterator

      public ListIterator<T> listIterator()
      Specified by:
      listIterator in interface List<T>
    • listIterator

      public ListIterator<T> listIterator(int index)
      Specified by:
      listIterator in interface List<T>
    • indexOf

      public int indexOf(Object o)
      Specified by:
      indexOf in interface List<T>
    • lastIndexOf

      public int lastIndexOf(Object o)
      Specified by:
      lastIndexOf in interface List<T>
    • set

      public T set(int index, T t)
      Specified by:
      set in interface List<T>
    • retainAll

      public boolean retainAll(Collection<?> c)
      Specified by:
      retainAll in interface Collection<T>
      Specified by:
      retainAll in interface List<T>
    • containsAll

      public boolean containsAll(Collection<?> c)
      Specified by:
      containsAll in interface Collection<T>
      Specified by:
      containsAll in interface List<T>
    • toArray

      public <T> T[] toArray(T[] a)
      Specified by:
      toArray in interface Collection<T>
      Specified by:
      toArray in interface List<T>
    • toArray

      public Object[] toArray()
      Specified by:
      toArray in interface Collection<T>
      Specified by:
      toArray in interface List<T>
    • addAll

      public boolean addAll(Collection<? extends T> c)
      Specified by:
      addAll in interface Collection<T>
      Specified by:
      addAll in interface List<T>
    • addAll

      public boolean addAll(int index, Collection<? extends T> c)
      Specified by:
      addAll in interface List<T>
    • removeAll

      public boolean removeAll(Collection<?> c)
      Specified by:
      removeAll in interface Collection<T>
      Specified by:
      removeAll in interface List<T>
    • clear

      public void clear()
      Specified by:
      clear in interface Collection<T>
      Specified by:
      clear in interface List<T>
    • getMost

      public T getMost(Comparator<? super T> c)
    • sort

      public void sort(Comparator<? super T> c)
      Specified by:
      sort in interface List<T>
    • addSorted

      public boolean addSorted(T t, Comparator<? super T> c)
    • iterator

      public Iterator<T> iterator()
      return the coresponding Iterator
      Specified by:
      iterator in interface Collection<T>
      Specified by:
      iterator in interface Iterable<T>
      Specified by:
      iterator in interface List<T>
    • writeObject

      private void writeObject(ObjectOutputStream stream) throws IOException
      Save Serializable list with a iterative implementation.
      This is used to avoid save issues with big saves.
      Throws:
      IOException
    • readObject

      private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException
      Load Serializable list with a iterative implementation.
      This is used to avoid save issues with big saves.
      Throws:
      IOException
      ClassNotFoundException