|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--jdsl.core.ref.ArraySkipList
| Inner classes inherited from class jdsl.core.api.InspectableDictionary |
InspectableDictionary.InvalidLocator |
| Field Summary | |
static int |
DEFAULT_MAX_LEVEL
Default maximum level of node. |
| Fields inherited from interface jdsl.core.api.InspectableOrderedDictionary |
BOUNDARY_VIOLATION |
| Fields inherited from interface jdsl.core.api.InspectableDictionary |
NO_SUCH_KEY |
| Constructor Summary | |
ArraySkipList(Comparator comparator)
Runs in O(1 + t) time where t is the time it takes to create the head node with (DEFAULT_MAX_LEVEL+1) forward links. |
|
ArraySkipList(Comparator comparator,
int maxLevel)
Runs in O(1 + t) time where t is the time it takes to create the head node with (DEFAULT_MAX_LEVEL+1) forward links. |
|
ArraySkipList(Comparator comparator,
int maxLevel,
long seed)
Runs in O(1 + t) time where t is the time it takes to create the head node with (maxLevel+1) forward links. |
|
| Method Summary | |
Locator |
after(Locator locator)
Runs in O(1) time. |
Locator |
before(Locator locator)
Runs in O(1) time. |
Locator |
closestAfter(Object key)
Runs in expected O(log n) time, where n is the number of elements. |
Locator |
closestBefore(Object key)
Runs in expected O(log n) time, where n is the number of elements. |
boolean |
contains(Accessor a)
Runs in O(1) time. |
ObjectIterator |
elements()
Runs in O(n) time, where n is the number of elements. |
Locator |
find(Object key)
Runs in expected O(log n) time, where n is the number of elements finds first node within skip list with key. |
LocatorIterator |
findAll(Object key)
Runs in expected O(log n + m) time where n is the total number of elements and m is the number of elements with key value equal to key. |
Locator |
first()
Runs in O(1) time. |
Locator |
insert(Object key,
Object element)
Runs in expected O(log n) time, where n is the number of elements in the skip list. |
boolean |
isEmpty()
Runs in O(1) time. |
ObjectIterator |
keys()
Runs in O(n) time, where n is the number of elements. |
Locator |
last()
Runs in O(1) time. |
LocatorIterator |
locators()
Runs in O(n) time, where n is the number of elements. |
Container |
newContainer()
Runs in O(1 + t) time where t is the time it takes to create the head node. |
void |
remove(Locator locator)
Runs in expected O(log n) time, where n is the number of elements. |
LocatorIterator |
removeAll(Object searchKey)
Runs in expected O(log n + k) where k is the number of duplicate keys and n is the number of elements. |
Locator |
removeKey(Object key)
Runs in expected O(log n) time, where n is the number of elements. |
Object |
replaceElement(Accessor a,
Object newElement)
Runs in O(1) time. |
Object |
replaceKey(Locator locator,
Object key)
Runs in expected O(log n) time, where n is the number of elements. |
int |
size()
Runs in O(1) time. |
String |
toString()
Runs in O(n) time, where n is the number of elements. |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
public static final int DEFAULT_MAX_LEVEL
| Constructor Detail |
public ArraySkipList(Comparator comparator,
int maxLevel,
long seed)
(maxLevel+1) forward links.
An ideal value for maxLevel would be.
log(N) where N is the total
number of elements expected.
Initializes head node.
Sets current level to 0, which is the minimum.comparator - comparator to use.maxLevel - highest level for any node.seed - seed for random number generator.
public ArraySkipList(Comparator comparator,
int maxLevel)
(DEFAULT_MAX_LEVEL+1) forward links.comparator - comparator to use.maxLevel - highest level for any node.public ArraySkipList(Comparator comparator)
(DEFAULT_MAX_LEVEL+1) forward links.comparator - comparator to use.| Method Detail |
public Container newContainer()
newContainer in interface Containerjdsl.core.api.Container
public Object replaceElement(Accessor a,
Object newElement)
throws InvalidAccessorException
replaceElement in interface Containerjdsl.core.api.Containera - Accessor in this containernewElement - to be stored at aInvalidAccessorException - if a is null or does not
belong to this container
public boolean contains(Accessor a)
throws InvalidAccessorException
contains in interface InspectableContainerjdsl.core.api.InspectableContainerInvalidAccessorException - if a is nullpublic int size()
size in interface InspectableContainerjdsl.core.api.InspectableContainerpublic boolean isEmpty()
isEmpty in interface InspectableContainerjdsl.core.api.InspectableContainertrue if and only if the container is empty (holds
no elements)InspectableBinaryTreepublic ObjectIterator elements()
elements in interface InspectableContainerjdsl.core.api.InspectableContainerpublic LocatorIterator locators()
locators in interface InspectableKeyBasedContainerjdsl.core.api.InspectableKeyBasedContainerpublic ObjectIterator keys()
keys in interface InspectableKeyBasedContainerjdsl.core.api.InspectableKeyBasedContainer
public Object replaceKey(Locator locator,
Object key)
throws InvalidAccessorException,
InvalidKeyException
replaceKey in interface KeyBasedContainerjdsl.core.api.KeyBasedContainerloc - the locator in the container whose key should be replacedkey - the new key to associate with loc.InvalidAccessorException - If the locator is not valid
or is not contained by this containerInvalidKeyException - If key cannot be used
by this container
public Locator find(Object key)
throws InvalidKeyException
after().find in interface InspectableDictionaryjdsl.core.api.InspectableDictionarykey - The key mapped to search for.Locator referring to the key-element pair
that was found, or NO_SUCH_KEY if it could not be found.InvalidKeyException - if the specified key is not a valid
key in this container.InspectableDictionary.NO_SUCH_KEY
public LocatorIterator findAll(Object key)
throws InvalidKeyException
key.
relies on find() returning first node in skip list containing key.findAll in interface InspectableDictionaryjdsl.core.api.InspectableDictionarykey - The key to search for.InvalidKeyException - if the specified key is not valid in
this container
public Locator closestBefore(Object key)
throws InvalidKeyException
closestBefore in interface InspectableOrderedDictionaryjdsl.core.api.InspectableOrderedDictionarykey - A valid key.key. Note: If no such locator exists, the
returned locator will be BOUNDARY_VIOLATION.InvalidKeyException - If key is not of a
type accepted by this Container (For example: the key is not
comparable).
public Locator closestAfter(Object key)
throws InvalidKeyException
closestAfter in interface InspectableOrderedDictionaryjdsl.core.api.InspectableOrderedDictionarykey - A valid key.key. Note: If no such Locator exists, the
returned locator will be BOUNDARY_VIOLATION.InvalidKeyException - If key is not of a
type accepted by this Container (For example: the key is not
comparable).
public Locator after(Locator locator)
throws InvalidAccessorException
after in interface InspectableOrderedDictionaryjdsl.core.api.InspectableOrderedDictionarylocator - An abstract position in this Container.
locator. Note: Will return the invalid
BOUNDARY_VIOLATION Locator if no such locator exists.InvalidAccessorException - If locator is
invalid (For example: It does not actually reference an element
within this Container).
public Locator before(Locator locator)
throws InvalidAccessorException
before in interface InspectableOrderedDictionaryjdsl.core.api.InspectableOrderedDictionarylocator - An abstract position in this Container.
locator. Note: Will return the invalid
BOUNDARY_VIOLATION Locator if no such locator exists.InvalidAccessorException - If locator is
invalid (For example: It does not actually reference an element
within this Container).
public Locator insert(Object key,
Object element)
throws InvalidKeyException
insert in interface KeyBasedContainerjdsl.core.api.KeyBasedContainerkey - the key associated with the specified element.element - the element to insert into the container.InvalidKeyException - if key cannot be used
by this container
public LocatorIterator removeAll(Object searchKey)
throws InvalidKeyException
key.removeAll in interface Dictionaryjdsl.core.api.Dictionarykey - the key to search forInvalidKeyException - if the specified key is not a
valid key in this container
public Locator removeKey(Object key)
throws InvalidKeyException
key - key to remove from container.InvalidKeyException - If the key is null or not compatible with container.
public void remove(Locator locator)
throws InvalidAccessorException
remove in interface KeyBasedContainerjdsl.core.api.KeyBasedContainerloc - a locator in the container to removeInvalidAccessorException - if the locator is not valid or
is not contained by this containerpublic Locator first()
first in interface InspectableOrderedDictionaryBOUNDARY_VIOLATION if list is empty.public Locator last()
last in interface InspectableOrderedDictionaryjdsl.core.api.InspectableOrderedDictionarypublic String toString()
toString in class Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||