|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.ivmaidns.util.ObservedCore net.sf.ivmaidns.storage.Storage net.sf.ivmaidns.storage.ObjectStorage net.sf.ivmaidns.storage.SortedStorage
public class SortedStorage
Class for ascending-sorted storage. Storage elements are placed during insertAt/setAt/readObject operations into ascending order according to the supplied comparator. If two (compared) elements are equal or uncomparable then they are ordered by their locations. Add, remove and search effectiveness is logarithmic.
Field Summary | |
---|---|
protected int |
approxLoc
NOTE: Used internally by setAt/locationOf/findLessGreater operations to speed up addressOf function. approxLoc must be either 0 or a non-empty location. |
protected GComparator |
comparator
NOTE: comparator must be ! |
protected int[] |
links
NOTE: links must be ! |
Fields inherited from class net.sf.ivmaidns.storage.ObjectStorage |
---|
elements |
Constructor Summary | |
---|---|
SortedStorage()
NOTE: The default comparator is used. |
|
SortedStorage(GComparator comparator)
NOTE: comparator must be ! |
Method Summary | |
---|---|
protected static int |
addressOf(java.lang.Object value,
int location,
java.lang.Object[] elements,
int[] links,
int approxLoc,
GComparator comparator)
NOTE: Find place for the child link to the value (value may be == null, location may be of any int value, abs(approxLoc) must be either 0 or a non-empty location, comparator must be ! |
protected static void |
changeLinks(int[] links,
int address,
int emptyLocation)
NOTE: If emptyLocation > 0 then another leaf is added to the tree else one leaf (which is refered by non-zero address) is removed. |
int |
childLocation(int parentLocation,
boolean forward)
NOTE: Must be synchronized outside. |
java.lang.Object |
clone()
NOTE: Must be synchronized outside. |
GComparator |
comparator()
NOTE: Result ! |
int |
emptyLocation()
NOTE: Result is an empty location (result > 0). |
int |
findLessGreater(java.lang.Object value,
boolean greater,
int prevLocation,
boolean forward)
NOTE: Search is performed using the supplied comparator. |
protected static int |
followLinks(int[] links,
int address)
NOTE: (address / 2) must be either 0 or a non-empty location. |
int |
insertAt(int prevLoc,
int emptyLocation,
java.lang.Object value)
NOTE: prevLoc must be >= 0, value must be comparable and insertion of this value must not destroy the order of elements in this storage (according to the semantics of sorted collection), otherwise ArrayStoreException is thrown. |
void |
integrityCheck()
NOTE: Shallow check for integrity of this object. |
int |
locationOf(java.lang.Object value,
int prevLocation,
boolean forward)
NOTE: Search is performed using the supplied comparator. |
protected void |
minimizeCapacity()
NOTE: Must be synchronized outside. |
void |
setApproxLoc(int approxLoc)
NOTE: This is a special operation for manual setting of approxLoc (approxLoc is also set internally by insertAt, setAt, locationOf and findLessGreater operations). approxLoc is entirely used internally to speed up setAt, locationOf and findLessGreater operations. approxLoc must be either 0 or a non-empty location, otherwise IllegalArgumentException is thrown. |
java.lang.Object |
setAt(int location,
java.lang.Object value)
NOTE: The effectiveness is logarithmic (may be nearly constant). |
int |
siblingLocation(int location,
boolean forward)
NOTE: Must be synchronized outside. |
Methods inherited from class net.sf.ivmaidns.storage.ObjectStorage |
---|
getAt, isValidAt, parentLocation |
Methods inherited from class net.sf.ivmaidns.storage.Storage |
---|
add, addAll, addAll, clear, contains, containsAll, containsAll, containsCount, equals, greaterThan, hasChildren, hashCode, insertAtAll, insertAtAll, nextLocation, notifyObservers, notifyObservers, remove, removeAll, removeAll, removeAt, toArray, toInlineString, toOutlineString, toString, trimToSize |
Methods inherited from class net.sf.ivmaidns.util.ObservedCore |
---|
addObserver, hasObservers, removeObserver |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected transient int[] links
protected final GComparator comparator
protected transient int approxLoc
Constructor Detail |
---|
public SortedStorage()
public SortedStorage(GComparator comparator) throws java.lang.NullPointerException
java.lang.NullPointerException
Method Detail |
---|
public final GComparator comparator()
protected void minimizeCapacity()
minimizeCapacity
in class ObjectStorage
protected static final int addressOf(java.lang.Object value, int location, java.lang.Object[] elements, int[] links, int approxLoc, GComparator comparator) throws java.lang.NullPointerException, java.lang.ArrayIndexOutOfBoundsException
java.lang.NullPointerException
java.lang.ArrayIndexOutOfBoundsException
protected static final int followLinks(int[] links, int address) throws java.lang.NullPointerException, java.lang.ArrayIndexOutOfBoundsException
java.lang.NullPointerException
java.lang.ArrayIndexOutOfBoundsException
protected static final void changeLinks(int[] links, int address, int emptyLocation) throws java.lang.NullPointerException, java.lang.ArrayIndexOutOfBoundsException
java.lang.NullPointerException
java.lang.ArrayIndexOutOfBoundsException
public final int emptyLocation()
Storage
emptyLocation
in class ObjectStorage
public int insertAt(int prevLoc, int emptyLocation, java.lang.Object value) throws java.lang.IllegalArgumentException, java.lang.ArrayStoreException
insertAt
in class ObjectStorage
java.lang.IllegalArgumentException
java.lang.ArrayStoreException
public final void setApproxLoc(int approxLoc) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public java.lang.Object setAt(int location, java.lang.Object value) throws java.lang.IllegalArgumentException
setAt
in class ObjectStorage
java.lang.IllegalArgumentException
public int childLocation(int parentLocation, boolean forward) throws java.lang.IllegalArgumentException
childLocation
in class ObjectStorage
java.lang.IllegalArgumentException
public int siblingLocation(int location, boolean forward) throws java.lang.IllegalArgumentException
siblingLocation
in class ObjectStorage
java.lang.IllegalArgumentException
public int locationOf(java.lang.Object value, int prevLocation, boolean forward) throws java.lang.IllegalArgumentException
locationOf
in class ObjectStorage
java.lang.IllegalArgumentException
public int findLessGreater(java.lang.Object value, boolean greater, int prevLocation, boolean forward) throws java.lang.IllegalArgumentException
findLessGreater
in class ObjectStorage
java.lang.IllegalArgumentException
public java.lang.Object clone()
clone
in interface ReallyCloneable
clone
in class ObjectStorage
null
) of this
instance.public void integrityCheck()
integrityCheck
in interface Verifiable
integrityCheck
in class ObjectStorage
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |