net.rim.device.api.collection.util
Class LongHashtableCollection

java.lang.Object
  extended by net.rim.device.api.collection.util.LongHashtableCollection
All Implemented Interfaces:
Collection, ReadableLongMap, ReadableSet, WritableLongMap

public final class LongHashtableCollection
extends Object
implements ReadableSet, ReadableLongMap, WritableLongMap

Hashtable collection using long integers as keys.

With this collection write operations occur as a map; read operations occur as a map or as a set.


Constructor Summary
LongHashtableCollection()
          Constructs a new LongHashTableCollection instance.
 
Method Summary
 boolean contains(Object element)
          Determines if this collection contains an element.
 boolean contains(long key)
          Determines if this collection contains an element with provided long integer key.
 Object get(long key)
          Retrieves element by long integer key.
 Enumeration getElements()
          Retrieves an enumeration of this collection's elements.
 int getElements(Object[] elements)
          Retrieves this collection's elements.
 long getKey(Object element)
          Retrieves long integer key by element.
 LongEnumeration getKeys()
          Retrieves an enumeration of this collection's keys.
 void put(long key, Object element)
          Assigns a key to an element, and places it in the collection.
 void remove(long key)
          Removes element by key.
 void removeAll()
          Removes all elements.
 int size()
          Retrieves the number of elements in this collection.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Constructor Detail

LongHashtableCollection

public LongHashtableCollection()
Constructs a new LongHashTableCollection instance.



Method Detail

put

public void put(long key,
                Object element)
Assigns a key to an element, and places it in the collection.

Specified by:
put in interface WritableLongMap
Parameters:
key - Long integer key for new element.
element - New element to add to collection.

remove

public void remove(long key)
Removes element by key.

Specified by:
remove in interface WritableLongMap
Parameters:
key - Key associated with element you want to retrieve.

removeAll

public void removeAll()
Removes all elements.

Specified by:
removeAll in interface WritableLongMap

size

public int size()
Retrieves the number of elements in this collection.

Specified by:
size in interface ReadableLongMap
Specified by:
size in interface ReadableSet
Returns:
Number of elements in this collection.

get

public Object get(long key)
Retrieves element by long integer key.

Specified by:
get in interface ReadableLongMap
Parameters:
uid - Key for desired element.
Returns:
Element associated with they key, or null if no element associated with this key.

getKey

public long getKey(Object element)
Retrieves long integer key by element.

Specified by:
getKey in interface ReadableLongMap
Parameters:
obj - Element for which you want the key.
Returns:
Key associated with your element, or -1 if no such element exists in this collection (and thus has no key).

contains

public boolean contains(long key)
Determines if this collection contains an element with provided long integer key.

Specified by:
contains in interface ReadableLongMap
Parameters:
key - Key to locate in this collection.
Returns:
True if this key exists in this collection (has an associated element); otherwise, false.

contains

public boolean contains(Object element)
Determines if this collection contains an element.

Specified by:
contains in interface ReadableSet
Parameters:
obj - Element to look for.
Returns:
True if this collection contains the element; otherwise, false.

getElements

public Enumeration getElements()
Retrieves an enumeration of this collection's elements.

Specified by:
getElements in interface ReadableSet
Returns:
Enumeration of this collection's elements.

getKeys

public LongEnumeration getKeys()
Retrieves an enumeration of this collection's keys.

Returns:
Enumeration of this collection's keys.
Since:
BlackBerry API 4.0.0

getElements

public int getElements(Object[] elements)
Retrieves this collection's elements.

The array you provide to contain the collection's elements must be large enough to contain them. Accordingly, you should synchronize on this collection, invoke LongHashtableCollection.size(), create an array of the required size, and then invoke this method.. This ensures that the collection's size won't change by the time you get to actually retrieving its elements.

This method also completely erases the current contents of your object array out-parameter.

Specified by:
getElements in interface ReadableSet
Parameters:
elements - Object array to contain returned elements; must be large enough to retrieve this collection's elements.
Returns:
Number of elements actually retrieved.





Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal