|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.isi.stella.Stella_Object edu.isi.stella.StandardObject edu.isi.stella.AbstractCollection edu.isi.stella.AbstractDictionary edu.isi.stella.Dictionary edu.isi.stella.KeyValueMap
public class KeyValueMap
Full-featured dictionary class that supports eqlP
or
equalP
equality tests, O(1) access operations even for large numbers
of entries by using a hash table, light-weight KV-CONS representation for
small tables and iteration even if the dictionary is represented by a
hash table.
Field Summary | |
---|---|
int |
crossoverPoint
|
boolean |
equalTestP
If true use equalP as the
equality test (and equalHashCode as the hash function), otherwise,
use eqlP (and hashCode ) (the default). |
int |
initialSize
If supplied, the initial table will be sized to hold at least that many elements. |
Stella_Object |
theMap
|
Constructor Summary | |
---|---|
KeyValueMap()
|
Method Summary | |
---|---|
static Stella_Object |
accessKeyValueMapSlotValue(KeyValueMap self,
Symbol slotname,
Stella_Object value,
boolean setvalueP)
|
AbstractIterator |
allocateIterator()
Allocate an iterator for self . |
void |
clear()
Reset self to have zero entries. |
Cons |
consify()
Collect all entries of self into a cons list of
_LkeyGLvalueG_ pairs and return the result. |
KeyValueMap |
copy()
Return a copy of the map self . |
boolean |
emptyP()
Return TRUE if self has zero entries. |
int |
equalHashCode()
Return an equalP hash code for self . |
void |
insertAt(Stella_Object key,
Stella_Object value)
Set the value of the entry identified by key in self
to value or add a new entry if no entry with key exists yet. |
int |
length()
Return the number of entries in self . |
Stella_Object |
lookup(Stella_Object key)
Lookup the entry identified by key in self and
return its value, or NULL if no such entry exists. |
static KeyValueMap |
newKeyValueMap()
|
boolean |
nonEmptyP()
Return TRUE if self has at least 1 entry. |
boolean |
objectEqualP(Stella_Object y)
Return TRUE if x and y represent the same set of key/value pairs. |
Surrogate |
primaryType()
Returns the primary type of self . |
void |
removeAt(Stella_Object key)
Remove the entry identified by key from self . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public Stella_Object theMap
public boolean equalTestP
equalP
as the
equality test (and equalHashCode
as the hash function), otherwise,
use eqlP
(and hashCode
) (the default).
public int initialSize
public int crossoverPoint
Constructor Detail |
---|
public KeyValueMap()
Method Detail |
---|
public static KeyValueMap newKeyValueMap()
public int equalHashCode()
equalP
hash code for self
. Note that this
is O(N) in the number of entries of self
.
equalHashCode
in class Stella_Object
public boolean objectEqualP(Stella_Object y)
x
and y
represent the same set of key/value pairs.
objectEqualP
in class Stella_Object
y
-
public Cons consify()
self
into a cons list of
_LkeyGLvalueG_
pairs and return the result.
consify
in class Stella_Object
public AbstractIterator allocateIterator()
self
. The only modifying
operations allowed during iteration are removal of the current element or
changing its value. All other removal or insertion operations might lead
to corruption or undefined results.
allocateIterator
in class Dictionary
public void clear()
self
to have zero entries.
public KeyValueMap copy()
self
. All entries are freshly
allocated, however, the keys and values of entries are not copied themselves
(similar to what we do for lists, etc.).
public boolean nonEmptyP()
self
has at least 1 entry.
public boolean emptyP()
self
has zero entries.
public int length()
self
.
length
in class AbstractCollection
public void removeAt(Stella_Object key)
key
from self
. Uses an
eqlP
test by default or equalP
if equalTestP
of self
is TRUE.
key
- public void insertAt(Stella_Object key, Stella_Object value)
key
in self
to value
or add a new entry if no entry with key
exists yet. Uses an
eqlP
test by default or equalP
if equalTestP
of self
is TRUE.
insertAt
in class Dictionary
key
- value
- public Stella_Object lookup(Stella_Object key)
key
in self
and
return its value, or NULL if no such entry exists. Uses an eqlP
test by default or equalP
if equalTestP
of self
is TRUE.
lookup
in class Dictionary
key
-
public static Stella_Object accessKeyValueMapSlotValue(KeyValueMap self, Symbol slotname, Stella_Object value, boolean setvalueP)
public Surrogate primaryType()
Stella_Object
self
.
Gets defined automatically for every non-abstract subclass of OBJECT.
primaryType
in class Stella_Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |