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>
An ordered hash map implementation.
  • Constructor Details

    • HashedList

      public HashedList()
  • Method Details

    • add

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

      public void update(String key, VALUE entry)
      Similar to add(VALUE), except this replaces an existing card that matches the specified key in-situ. At the same time, new entries are added at the current position.
      Parameters:
      key - The key of the existing card (if any) to be replaced).
      entry - The element to add to the list.
    • 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)
      Checks if the list contains an entry for the given keyword.
      Parameters:
      key - the key to search
      Returns:
      true if the key is included in the list, otherwise false.
    • get

      public VALUE get(int n)
      Returns the element for a given index from the odered list.
      Parameters:
      n - the index to get
      Returns:
      the n'th entry from the beginning.
    • get

      public VALUE get(Object key)
      Returns the element for the given hash 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.
      See Also:
    • isEmpty

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

      public HashedList<VALUE>.nom.tam.util.HashedList.HashedListIterator iterator()
      Returns an iterator that will go over all elements of the list in the defined order.
      Specified by:
      iterator in interface Collection<VALUE extends CursorValue<String>>
      Specified by:
      iterator in interface Iterable<VALUE extends CursorValue<String>>
      Returns:
      an interator over the entire list.
      See Also:
    • iterator

      public Cursor<String,VALUE> iterator(int n)
      Returns an iterator, which starts from the specified entry index, and goes over the remaining elements in the list.
      Parameters:
      n - the index to start the iterator
      Returns:
      an iterator starting with the n'th entry.
      See Also:
    • cursor

      public Cursor<String,VALUE> cursor()
      Return the iterator that represents the current position in the header. This provides a connection between editing headers through Header add/append/update methods, and via Cursors, which can be used side-by-side while maintaining desired card ordering. For the reverse direction ( translating iterator position to current position in the header), we can just use findCard().
      Returns:
      the iterator representing the current position in the header.
      See Also:
    • iterator

      public HashedList<VALUE>.nom.tam.util.HashedList.HashedListIterator iterator(String key)
      Returns an iterator, which starts from the specified keyed entry, and goes over the remaining elements in the list.
      Parameters:
      key - the key to use as a start point
      Returns:
      an iterator over the list starting with the entry with a given key.
      See Also:
    • 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
    • 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