Package nom.tam.util

Class HashedList<VALUE extends CursorValue<String>>

java.lang.Object
nom.tam.util.HashedList<VALUE>
Type Parameters:
VALUE - value of the map
All Implemented Interfaces:
Iterable<VALUE>, Collection<VALUE>

public class HashedList<VALUE extends CursorValue<String>> extends Object implements Collection<VALUE>
a ordered hash map implementation.
  • Field Details

  • Constructor Details

    • HashedList

      public HashedList()
  • Method Details

    • add

      private void add(int pos, VALUE reference)
      Add an element to the list at a specified position. If that element was already in the list, it is first removed from the list then added again - if it was removed from a position before the position where it was to be added, that position is decremented by one.
      Parameters:
      pos - The position at which the specified element is to be added. If pos is bigger than the size of the list the element is put at the end of the list.
      reference - The element to add to the list.
    • unkeyedKey

      private static boolean unkeyedKey(String key)
    • add

      public boolean add(VALUE e)
      Specified by:
      add in interface Collection<VALUE extends CursorValue<String>>
    • addAll

      public boolean addAll(Collection<? extends VALUE> c)
      Specified by:
      addAll in interface Collection<VALUE extends CursorValue<String>>
    • clear

      public void clear()
      Specified by:
      clear in interface Collection<VALUE extends CursorValue<String>>
    • contains

      public boolean contains(Object o)
      Specified by:
      contains in interface Collection<VALUE extends CursorValue<String>>
    • containsAll

      public boolean containsAll(Collection<?> c)
      Specified by:
      containsAll in interface Collection<VALUE extends CursorValue<String>>
    • containsKey

      public boolean containsKey(Object key)
      Parameters:
      key - the key to search
      Returns:
      true if the key is included in the list.
    • get

      public VALUE get(int n)
      Parameters:
      n - the index to get
      Returns:
      the n'th entry from the beginning.
    • get

      public VALUE get(Object key)
      Parameters:
      key - the key to search for
      Returns:
      the value of a keyed entry. Non-keyed entries may be returned by requesting an iterator.
    • indexOf

      int indexOf(VALUE entry)
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Collection<VALUE extends CursorValue<String>>
    • iterator

      public HashedList<VALUE>.HashedListIterator iterator()
      Specified by:
      iterator in interface Collection<VALUE extends CursorValue<String>>
      Specified by:
      iterator in interface Iterable<VALUE extends CursorValue<String>>
      Returns:
      a HashedListIterator over the entire list.
    • iterator

      public Cursor<String,VALUE> iterator(int n)
      Parameters:
      n - the index to start the iterator
      Returns:
      an iterator starting with the n'th entry.
    • iterator

      public HashedList<VALUE>.HashedListIterator iterator(String key)
      Parameters:
      key - the key to use as a start point
      Returns:
      an iterator over the list starting with the entry with a given key.
    • remove

      public boolean remove(int index)
      Remove an object from the list giving the object index..
      Parameters:
      index - the index to remove
      Returns:
      true if the index was in range
    • internalRemove

      private boolean internalRemove(int index, VALUE entry)
    • remove

      public boolean remove(Object o)
      Specified by:
      remove in interface Collection<VALUE extends CursorValue<String>>
    • removeAll

      public boolean removeAll(Collection<?> c)
      Specified by:
      removeAll in interface Collection<VALUE extends CursorValue<String>>
    • removeKey

      public boolean removeKey(Object key)
      Remove a keyed object from the list. Unkeyed objects can be removed from the list using a HashedListIterator or using the remove(Object) method.
      Parameters:
      key - the key to remove
      Returns:
      true if the key was removed
    • replaceKey

      public boolean replaceKey(String oldKey, String newKey)
      Replace the key of a given element.
      Parameters:
      oldKey - The previous key. This key must be present in the hash.
      newKey - The new key. This key must not be present in the hash.
      Returns:
      if the replacement was successful.
    • retainAll

      public boolean retainAll(Collection<?> c)
      Specified by:
      retainAll in interface Collection<VALUE extends CursorValue<String>>
    • size

      public int size()
      Specified by:
      size in interface Collection<VALUE extends CursorValue<String>>
    • sort

      public void sort(Comparator<String> comp)
      Sort the keys into some desired order.
      Parameters:
      comp - the comparator to use for the sorting
    • toArray

      public Object[] toArray()
      Specified by:
      toArray in interface Collection<VALUE extends CursorValue<String>>
    • toArray

      public <T> T[] toArray(T[] o)
      Specified by:
      toArray in interface Collection<VALUE extends CursorValue<String>>
    • toString

      public String toString()
      Overrides:
      toString in class Object