Class IDObjectMap
java.lang.Object
com.aquima.interactions.matching.util.IDObjectMap
- All Implemented Interfaces:
Serializable
Slightly modified version of the IDArray class to enable a weight to be attached to an id.
Copyright: Copyright (c) 2004
Company:
- Since:
- 6.2
- Author:
- O. Kerpershoek
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Iterator class that can be used to iterate over the contents of an IDObjectMap class. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs the map with an initial size of zero.IDObjectMap
(int initialSize) Constructs the map with an initial size. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Removes all items from the array by resetting the size to zero.boolean
contains
(int id) This method checks if the given id is present in the array.get
(int id) This method returns the object for the specified ID.boolean
isEmpty()
This method returns true if the array is empty, false otherwise.iterator()
This method returns an iterator that can be used to iterate over the contents of the map.boolean
Add the id to the array.remove
(int id) Remove the given id from the array.int
size()
This method returns the number of id's present in the array.toString()
-
Constructor Details
-
Method Details
-
put
Add the id to the array. This operation might cause the internal size to be expanded. The id's are stored internally in a sorted order, with the smallest id at the front of the array.- Parameters:
id
- The id that should be added to the array.objValue
- The object value that should be associated with the ID.- Returns:
- true if the id was added, false if the id was already present.
-
remove
Remove the given id from the array. The internal size is not affected by this operation.- Parameters:
id
- the id that should be removed from the array.- Returns:
- The Object belonging to id that was removed, or null if the id was not found.
-
clear
public void clear()Removes all items from the array by resetting the size to zero. -
get
This method returns the object for the specified ID.- Parameters:
id
- The ID for which the object is requested.- Returns:
- The object associated with the ID, or null is no object is available with the specified ID.
-
contains
public boolean contains(int id) This method checks if the given id is present in the array. This operation is 'highly' optimized, and takes log(n) time... well actually, I don't know, but the log(n) always looks cool :-)- Parameters:
id
- The id that should be checked.- Returns:
- true if the is present, false otherwise.
-
iterator
This method returns an iterator that can be used to iterate over the contents of the map.- Returns:
- an iterator that can be used to iterate over the contents of the map.
-
size
public int size()This method returns the number of id's present in the array.- Returns:
- the number of id's present in the array.
-
isEmpty
public boolean isEmpty()This method returns true if the array is empty, false otherwise.- Returns:
- true if the array is empty, false otherwise.
-
toString
-