edu.gwu.algtest
Interface OrderedSearchAlgorithm
- All Superinterfaces:
- edu.gwu.algtest.Algorithm, edu.gwu.algtest.SearchAlgorithm
- public interface OrderedSearchAlgorithm
- extends edu.gwu.algtest.SearchAlgorithm
Algorithms that search in ordered sets should implement
interface OrderedSearchAlgorithm
.
- See Also:
SearchAlgorithm
Method Summary |
java.lang.Object |
delete(java.lang.Comparable key)
delete should remove the key-value pair identified
by the input key from the data and return the associated value. |
java.lang.Object |
insert(java.lang.Comparable key,
java.lang.Object value)
insert will be given a key-value pair to
insert into the internal data structure of the algorithm. If the
key already exists, replace the existing value with the new value and
return the old value. |
edu.gwu.algtest.ComparableKeyValuePair |
maximum()
maximum should return the key-value pair with largest key. |
edu.gwu.algtest.ComparableKeyValuePair |
minimum()
minimum should return the key-value pair with least key. |
java.lang.Comparable |
predecessor(java.lang.Comparable key)
predecessor should return the key immediately preceding
(in sort order) the input key that is already in the data structure,
if one exists. |
edu.gwu.algtest.ComparableKeyValuePair |
search(java.lang.Comparable key)
search will be given a key and be expected
to return null if the key is not present
(was not inserted earlier), or return the key-value
pair if present. |
java.lang.Comparable |
successor(java.lang.Comparable key)
successor should return the key immediately following
(in sort order) the input key that is already in the data structure,
if one exists. |
Methods inherited from interface edu.gwu.algtest.SearchAlgorithm |
getCurrentSize, getKeys, getValues, initialize |
Methods inherited from interface edu.gwu.algtest.Algorithm |
getName, setPropertyExtractor |
insert
public java.lang.Object insert(java.lang.Comparable key,
java.lang.Object value)
insert
will be given a key-value pair to
insert into the internal data structure of the algorithm.
- Parameters:
key
- a Comparable
valuevalue
- an Object
value- Returns:
- an
Object
value
search
public edu.gwu.algtest.ComparableKeyValuePair search(java.lang.Comparable key)
search
will be given a key and be expected
to return null
if the key is not present
(was not inserted earlier), or return the key-value
pair if present.
- Parameters:
key
- a Comparable
value- Returns:
- a
ComparableKeyValuePair
value
minimum
public edu.gwu.algtest.ComparableKeyValuePair minimum()
minimum
should return the key-value pair with least key.
- Returns:
- a
ComparableKeyValuePair
value
maximum
public edu.gwu.algtest.ComparableKeyValuePair maximum()
maximum
should return the key-value pair with largest key.
- Returns:
- a
ComparableKeyValuePair
value
delete
public java.lang.Object delete(java.lang.Comparable key)
delete
should remove the key-value pair identified
by the input key from the data and return the associated value.
If the key is not found, return null.
- Parameters:
key
- a Comparable
value- Returns:
- an
Object
value
successor
public java.lang.Comparable successor(java.lang.Comparable key)
successor
should return the key immediately following
(in sort order) the input key that is already in the data structure,
if one exists. Return null otherwise. Thus, if the data consists of
keys "B", "C" and "D", a call to successor with "B" will return "C"
whereas a call with "A" (because "A" is not in the structure) or "D"
(because it's the largest) will return null.
- Parameters:
key
- a Comparable
value- Returns:
- a
Comparable
value
predecessor
public java.lang.Comparable predecessor(java.lang.Comparable key)
predecessor
should return the key immediately preceding
(in sort order) the input key that is already in the data structure,
if one exists. Return null otherwise. Thus, if the data consists of keys
"B", "C" and "D", a call to predecessor with "C" will return "B"
whereas a call with "A" (because "A" is the least) or "E"
(because "E" is not in the structure) will return null.
- Parameters:
key
- a Comparable
value- Returns:
- a
Comparable
value