public class

HashList

extends Object
implements Serializable Cloneable
java.lang.Object
   ↳ com.microstrategy.utils.HashList<K, V>

Class Overview

The HashList class allows the user to add, remove and examine the s in a given collection. The s can be access either by the index or by the key in the collection. This collection can also be used as read only.

Summary

Public Constructors
HashList()
Constructs a new, empty Collection with a default read-only value of false.
HashList(int initialCapacity)
Public Methods
void add(K key, V newItem)
Adds the , with the specified key, into the collection.
void clear()
Clears all items from the collection.
Object clone()
boolean containsKey(K key)
Returns true if the key is already in the collection, false otherwise.
boolean containsValue(V value)
Returns true if this collection maps one or more keys to the specified value.
Enumeration<V> elements()
Return the enumeration of the items inside this list.
V get(int index)
Gets the contained in the specified index of the collection.
V get(K key)
Returns the contained with the specified key in the collection.
HashMap<K, V> getItemSet()
This method is deprecated. replaced by items()
K getKey(int index)
Gets the key of the item contained in the specified index of the collection.
ArrayList<K> getKeyList()
This method is deprecated. replaced by keys()
int indexOf(K key)
Returns the index of the given key.
boolean isEmpty()
Returns true if the collection is empyt, false otherwise.
Map<K, V> items()
Returns an unmodifiable Map of the items.
List<K> keys()
Returns an unmodifiable List of the keys.
void put(K key, V newItem)
Adds or replaces the , with the specified key, into the collection.
void putAll(Map<K, V> m)
Adds all the s in the map to the collection
void putAll(HashList<K, V> list)
Adds all the s in the HashList in the same order defined in it.
V remove(int index)
Removes the contained in the specified index of the collection.
V remove(K key)
Removes the contained with the specified key in the collection.
V replace(K key, V newItem)
Replace the current item associated with the given key.
void setItemSet(HashMap<K, V> newValue)
This method is deprecated. dangerous method pending removal
void setKeyList(ArrayList<K> newValue)
This method is deprecated. dangerous method pending removal
int size()
Returns the current size of the collection.
void sort(Comparator<K> comp)
Sorts the existing list according to the order induced by the specified comparator.
String toString()
Returns a string representation of the .
Collection<V> values()
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public HashList ()

Constructs a new, empty Collection with a default read-only value of false.

public HashList (int initialCapacity)

Public Methods

public void add (K key, V newItem)

Adds the , with the specified key, into the collection. Throws UnsupportedOperationException in case the collection is a read-only ; and IllegalArgumentException in case the key is null, or it already exists in the collection.

Parameters
key The key used to identify the in the collection.
newItem The to add to the collection.
Throws
IllegalArgumentException Thrown if the given key is already contained in the collection.

public void clear ()

Clears all items from the collection.

public Object clone ()

Throws
CloneNotSupportedException

public boolean containsKey (K key)

Returns true if the key is already in the collection, false otherwise.

Parameters
key The key that we want to look for in the collection.
Returns
  • Wheter the collection contains the key.

public boolean containsValue (V value)

Returns true if this collection maps one or more keys to the specified value.

Parameters
value value whose presence in this collection is to be tested.
Returns
  • true if this collection maps one or more keys to the specified value.

public Enumeration<V> elements ()

Return the enumeration of the items inside this list.

Returns
  • An enumeration of the items inside this list.

public V get (int index)

Gets the contained in the specified index of the collection. Throws IndexOutOfBoundsException in case the index is greater than the collection size or < 0.

Parameters
index The index of the item in the collection to get.
Returns
  • the value contained in the specified index of the collection.
Throws
IndexOutOfBoundsException Thrown if no item in the collection has the given index.

public V get (K key)

Returns the contained with the specified key in the collection. Throws IllegalArgumentException in case the key does not exist in the collection.

Parameters
key The key of the item in the collection to get.
Returns
  • the value to which collection maps the specified key.
Throws
IllegalArgumentException Thrown if no item in the collection has the given key.

public HashMap<K, V> getItemSet ()

This method is deprecated.
replaced by items()

Do NOT use! Altering the contents of the Map can corrupt the underlying HashList.

public K getKey (int index)

Gets the key of the item contained in the specified index of the collection. Throws IndexOutOfBoundsException in case the index is greater than the collection size or < 0.

Parameters
index The index of the item in the collection.
Returns
  • the key of the item contained in the specified index of the collection.
Throws
IndexOutOfBoundsException thrown if no item in the collection has the given index.

public ArrayList<K> getKeyList ()

This method is deprecated.
replaced by keys()

Do NOT use! Altering the contents of the Map can corrupt the underlying HashList.

public int indexOf (K key)

Returns the index of the given key.

Parameters
key that represents the key.
Returns
  • the index of the key in the collection, -1 if the is not found.

public boolean isEmpty ()

Returns true if the collection is empyt, false otherwise.

Returns
  • Whether the collection is empty.

public Map<K, V> items ()

Returns an unmodifiable Map of the items.

public List<K> keys ()

Returns an unmodifiable List of the keys.

public void put (K key, V newItem)

Adds or replaces the , with the specified key, into the collection. Throws UnsupportedOperationException in case the collection is a read-only

Parameters
key The key used to identify the in the collection.
newItem The to add to the collection.
Throws
IllegalArgumentException Thrown if the given key is already contained in the collection.

public void putAll (Map<K, V> m)

Adds all the s in the map to the collection

Parameters
m A Map with a list of key/value entries.
Throws
IllegalArgumentException Thrown if any of the given keys is already contained in the collection.

public void putAll (HashList<K, V> list)

Adds all the s in the HashList in the same order defined in it.

Parameters
list A HashList with a list of key/value entries.
Throws
IllegalArgumentException Thrown if any of the given keys is already contained in the collection.

public V remove (int index)

Removes the contained in the specified index of the collection. Throws IndexOutOfBoundsException in case the index is greater than the collection size or < 0; and UnsupportedOperationException in case the collection is a read-only .

Parameters
index The index of the item in the collection to remove.
Returns
  • previous value in the specified index of the collection.
Throws
IndexOutOfBoundsException Thrown if no item in the collection has the given index.

public V remove (K key)

Removes the contained with the specified key in the collection. Throws IllegalArgumentException if the key is not contained in the collection; and UnsupportedOperationException in case the collection is a read-only .

Parameters
key The key of the item in the collection to remove.
Returns
  • previous value associated with specified key.
Throws
IllegalArgumentException Thrown if no item in the collection has the given key.

public V replace (K key, V newItem)

Replace the current item associated with the given key. Returns the item that was previously associated. Throws an exception If there is no element with the given value or with a null key.

Parameters
key the key of the element to replace
newItem the new item to be inserted.
Returns
  • the previously associated with that key.

public void setItemSet (HashMap<K, V> newValue)

This method is deprecated.
dangerous method pending removal

Do NOT use! Altering the contents of the Map can corrupt the underlying HashList.

public void setKeyList (ArrayList<K> newValue)

This method is deprecated.
dangerous method pending removal

Do NOT use! Altering the contents of the Map can corrupt the underlying HashList.

public int size ()

Returns the current size of the collection.

Returns
  • The number of items in the collection.

public void sort (Comparator<K> comp)

Sorts the existing list according to the order induced by the specified comparator.

public String toString ()

Returns a string representation of the .

Returns
  • a string representation of the .

public Collection<V> values ()