|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.neu.ccs.quick.StringObjectMap
StringObjectMap encapsulates a structure that maintains
a collection of String and Object pairs in
such a way that the original order of pair entry is preserved and it is
efficient to map a string to an object and vice versa.
| Field Summary | |
private QuickHashMap |
objectToStringMap
The object to string map. |
private QuickVector |
pairList
The vector of string-object pairs in order. |
private QuickTreeMap |
stringToObjectMap
The string to object map. |
| Constructor Summary | |
StringObjectMap()
The default constructor. |
|
StringObjectMap(Object[][] pairs)
The constructor with an array of string-object pairs as a 2-dimensional array of Object. |
|
StringObjectMap(StringObjectPair[] pairs)
The constructor with an array of StringObjectPairs. |
|
| Method Summary | |
boolean |
addPair(int index,
String string,
Object object)
Adds the given String and Object
pair to the StringObjectMap at the given index. |
boolean |
addPair(int index,
StringObjectPair pair)
Adds the given StringObjectPair pair to the
StringObjectMap at the given index. |
boolean |
addPair(String string,
Object object)
Adds the given String and Object
pair to the StringObjectMap. |
boolean |
addPair(StringObjectPair pair)
Adds the given StringObjectPair pair to the
StringObjectMap. |
void |
addPairs(Object[][] array)
Adds an array of string-object pairs to the map. |
void |
addPairs(StringObjectPair[] pairs)
Adds an array of StringObjectPair pairs to the map. |
void |
clear()
Clear the map of all strings and objects. |
boolean |
containsObject(Object object)
Returns true if this map contains the Object. |
boolean |
containsString(String string)
Returns true if this map contains the String. |
Object |
getObject(int index)
Returns the Object at the given index in order of
entry into the map; or null if the index is out of
bounds. |
Object |
getObject(String string)
Returns the Object associated with the given
String or null if no association
is found. |
Object[] |
getObjects()
Returns as an array the Objects in this map
in order of entry into the map. |
StringObjectPair |
getPair(int index)
Returns the StringObjectPair pair at the given
index in order of entry into the map; or null if
the index is out of bounds. |
Object[] |
getSortedObjects()
Returns as an array the Objects in this map
sorted in order of their corresponding strings order. |
StringObjectPair[] |
getSortedStringObjectPairs()
Returns as an array the StringObjectPair pairs in
this map sorted in order of their corresponding strings order. |
String[] |
getSortedStrings()
Returns as an array the Strings in this map
in sorted order. |
String |
getString(int index)
Returns the String at the given index in order of
entry into the map; or null if the index is out of
bounds. |
String |
getString(Object object)
Returns the String associated with the given
Object or null if no association
is found. |
StringObjectPair[] |
getStringObjectPairs()
Returns as an array the StringObjectPair pairs
in this map in order of entry into the map. |
String[] |
getStrings()
Returns as an array the Strings in this map
in order of entry into the map. |
StringObjectPair |
remove(int index)
Removes and returns the pair corresponding to the given index in order of entry in the map provided that the index is in bounds; otherwise returns null. |
StringObjectPair |
removeByObject(Object object)
Removes and returns a pair corresponding to the given Object object provided that the object is in
the map; otherwise returns null. |
StringObjectPair |
removeByString(String string)
Removes and returns a pair corresponding to the given String string provided that the string is in
the map; otherwise returns null. |
void |
setPairs(Object[][] array)
Clears the map and adds an array of string-object pairs to the map. |
void |
setPairs(StringObjectPair[] pairs)
Clears the map and adds an array of StringObjectPair
pairs to the map. |
int |
size()
Returns the number of string-object pairs in this map. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private QuickTreeMap stringToObjectMap
private QuickHashMap objectToStringMap
private QuickVector pairList
| Constructor Detail |
public StringObjectMap()
StringObjectMap(Object[][]),
StringObjectMap(StringObjectPair[])public StringObjectMap(Object[][] pairs)
The constructor with an array of string-object pairs as a
2-dimensional array of Object.
pairs - the array of string-object pairsStringObjectMap(),
StringObjectMap(StringObjectPair[])public StringObjectMap(StringObjectPair[] pairs)
The constructor with an array of StringObjectPairs.
pairs - the array of string-object pairsStringObjectMap(),
StringObjectMap(StringObjectPair[])| Method Detail |
public boolean addPair(String string,
Object object)
Adds the given String and Object
pair to the StringObjectMap.
The string and object must both be non-null
or else does nothing.
Neither the string nor the object can already appear in the corresponding slot of this map. Does nothing if such a duplication is detected.
string - the string to enter into the mapobject - the associated object to enter into the map
addPair(StringObjectPair),
addPair(int, String, Object),
addPair(int, StringObjectPair)public boolean addPair(StringObjectPair pair)
Adds the given StringObjectPair pair to the
StringObjectMap.
If the pair is null then does nothing.
Neither the string nor the object in this pair can already appear in the corresponding slot of this map. Does nothing if such a duplication is detected.
pair - the string-object pair to enter into the map
addPair(String, Object),
addPair(int, String, Object),
addPair(int, StringObjectPair)
public boolean addPair(int index,
String string,
Object object)
Adds the given String and Object
pair to the StringObjectMap at the given index.
The string and object must both be non-null
or else does nothing.
Neither the string nor the object can already appear in the corresponding slot of this map. Does nothing if such a duplication is detected.
Does nothing if (index < 0) or if (index > size()).
index - the insert positionstring - the string to enter into the mapobject - the associated object to enter into the map
addPair(String, Object),
addPair(StringObjectPair),
addPair(int, StringObjectPair)
public boolean addPair(int index,
StringObjectPair pair)
Adds the given StringObjectPair pair to the
StringObjectMap at the given index.
If the pair is null then does nothing.
Neither the string nor the object in this pair can already appear in the corresponding slot of this map. Does nothing if such a duplication is detected.
Does nothing if (index < 0) or if (index > size()).
index - the insert positionpair - the string-object pair to enter into the map
addPair(String, Object),
addPair(StringObjectPair),
addPair(int, String, Object)public void addPairs(Object[][] array)
Adds an array of string-object pairs to the map.
array - the array of string-object pairsaddPairs(StringObjectPair[])public void addPairs(StringObjectPair[] pairs)
Adds an array of StringObjectPair pairs to the map.
pairs - the array of string-object pairsaddPairs(Object[][])public void setPairs(Object[][] array)
Clears the map and adds an array of string-object pairs to the map.
If array is null, then only clears.
array - the array of string-object pairspublic void setPairs(StringObjectPair[] pairs)
Clears the map and adds an array of StringObjectPair
pairs to the map.
If pairs is null, then only clears.
pairs - the array of string-object pairspublic StringObjectPair remove(int index)
Removes and returns the pair corresponding to the given
index in order of entry in the map provided that the index
is in bounds; otherwise returns null.
index - the index of the pair
removeByString(String),
removeByObject(Object)public StringObjectPair removeByString(String string)
Removes and returns a pair corresponding to the given
String string provided that the string is in
the map; otherwise returns null.
string - the string association to remove
remove(int),
removeByObject(Object)public StringObjectPair removeByObject(Object object)
Removes and returns a pair corresponding to the given
Object object provided that the object is in
the map; otherwise returns null.
object - the object association to remove
remove(int),
removeByString(String)public void clear()
public int size()
public String getString(Object object)
Returns the String associated with the given
Object or null if no association
is found.
object - the object to associate with a string
getObject(String),
getPair(int),
getString(int),
getObject(int)public Object getObject(String string)
Returns the Object associated with the given
String or null if no association
is found.
string - the string to associate with an object
getString(Object),
getPair(int),
getString(int),
getObject(int)public StringObjectPair getPair(int index)
Returns the StringObjectPair pair at the given
index in order of entry into the map; or null if
the index is out of bounds.
If the index is in bounds, this method is equivalent to
getStringObjectPairs()[index] but is more
efficient since no array is constructed.
index - the index of the pair
getString(Object),
getObject(String),
getString(int),
getObject(int)public String getString(int index)
Returns the String at the given index in order of
entry into the map; or null if the index is out of
bounds.
If the index is in bounds, this method is equivalent to
getStrings()[index] but is more efficient since no
array is constructed.
index - the index of the string
getString(Object),
getObject(String),
getPair(int),
getObject(int)public Object getObject(int index)
Returns the Object at the given index in order of
entry into the map; or null if the index is out of
bounds.
If the index is in bounds, this method is equivalent to
getObjects()[index] but is more efficient since no
array is constructed.
index - the index of the object
getString(Object),
getObject(String),
getPair(int),
getString(int)public StringObjectPair[] getStringObjectPairs()
Returns as an array the StringObjectPair pairs
in this map in order of entry into the map.
getStrings(),
getObjects(),
getSortedStringObjectPairs(),
getSortedStrings(),
getSortedObjects()public String[] getStrings()
Returns as an array the Strings in this map
in order of entry into the map.
getStringObjectPairs(),
getObjects(),
getSortedStringObjectPairs(),
getSortedStrings(),
getSortedObjects()public Object[] getObjects()
Returns as an array the Objects in this map
in order of entry into the map.
getStringObjectPairs(),
getStrings(),
getSortedStringObjectPairs(),
getSortedStrings(),
getSortedObjects()public StringObjectPair[] getSortedStringObjectPairs()
Returns as an array the StringObjectPair pairs in
this map sorted in order of their corresponding strings order.
getStringObjectPairs(),
getStrings(),
getObjects(),
getSortedStrings(),
getSortedObjects()public String[] getSortedStrings()
Returns as an array the Strings in this map
in sorted order.
getStringObjectPairs(),
getStrings(),
getObjects(),
getSortedStringObjectPairs(),
getSortedObjects()public Object[] getSortedObjects()
Returns as an array the Objects in this map
sorted in order of their corresponding strings order.
getStringObjectPairs(),
getStrings(),
getObjects(),
getSortedStringObjectPairs(),
getSortedStrings()public boolean containsString(String string)
true if this map contains the String.
string - the string to test
containsObject(Object)public boolean containsObject(Object object)
true if this map contains the Object.
object - the object to test
containsString(String)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||