|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.garret.serme.Persistent org.garret.serme.SortedCollection
Indexed collection providing fast access and sorting of their members. Members of the collection are sorted using provided user defined comparator. The instance of comparator class is also stored in database and provides methods for comparing collection members with each other and with key. SortedCollection is implemented using T-Tree, optimizing both speed of main operations (insert/find/remove) and space used by collection in memory.
Constructor Summary | |
SortedCollection()
Default constructor internally used by SerMe |
|
SortedCollection(IComparator comparator,
boolean unique)
Constructor of sorted collection |
Method Summary | |
boolean |
add(java.lang.Object obj)
Add new member to collection |
void |
clear()
Remove all objects from the collection |
boolean |
contains(java.lang.Object member)
Check if collections contains specified member |
java.util.Enumeration |
elements()
Get enumeration for all collection members. |
java.lang.Object |
get(java.lang.Object key)
|
java.lang.Object[] |
get(java.lang.Object from,
java.lang.Object till)
|
IComparator |
getComparator()
Get comparator used in this collection |
int |
getCounter()
This method is used internally by SerMe to detect concurrent modifications |
void |
readObject(IInputStream in)
Unpack object |
void |
remove(java.lang.Object obj)
Remove member from collection |
int |
size()
Get number of objects in the collection |
java.lang.Object[] |
toArray()
Get all objects in the index as array ordered by index key. |
java.lang.Object[] |
toArray(java.lang.Object[] arr)
Get all objects in the index as array ordered by index key. |
void |
writeObject(IOutputStream out)
Pack object |
Methods inherited from class org.garret.serme.Persistent |
getStorage, remove, setStorage, store |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public SortedCollection()
public SortedCollection(IComparator comparator, boolean unique)
comparator
- class used to compare collection members with each other and with keyunique
- if key should be unique in collectionMethod Detail |
public boolean add(java.lang.Object obj)
obj
- new member
true
if object is successfully added in the index,
false
if collection was declared as unique and there is already member with such value
of the key in the collection.public void clear()
public boolean contains(java.lang.Object member)
true
if specified member belongs to the collectionpublic java.util.Enumeration elements()
SermeException("Concurrent modification")
exception will be thrown.
public java.lang.Object get(java.lang.Object key)
public java.lang.Object[] get(java.lang.Object from, java.lang.Object till)
public IComparator getComparator()
public int getCounter()
public void readObject(IInputStream in)
in
- input streampublic void remove(java.lang.Object obj)
obj
- member to be removed
StorageError(StorageError.KEY_NOT_FOUND)
- exception if there is no such key in the collectionpublic int size()
public java.lang.Object[] toArray()
public java.lang.Object[] toArray(java.lang.Object[] arr)
public void writeObject(IOutputStream out)
out
- output stream
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |