Class IDScoreMap
java.lang.Object
com.aquima.interactions.matching.util.IDScoreMap
- All Implemented Interfaces:
Serializable
Map implementation that maps ID's to scores.
- Since:
- 6.2
- Author:
- O. Kerpershoek, F. van der Meer
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Iterator class that can be used to iterate over the contents of an IDScoreMap class. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd
(int id, int score) Add the score to the array.void
clear()
Removes all items from the array by resetting the size to zero.boolean
contains
(int id) This method returns a boolean indicating if a score is present for the specified ID.int
This method returns the highest score that is present in the map.int
This method returns the lowest score that is present in the map.int
This method returns the maximum size the map may reach.boolean
isEmpty()
This method returns true if the array is empty, false otherwise.boolean
isFull()
This method returns true if the array is filled with the maximum amount of scores, false otherwise.iterator()
This method returns an iterator that may be used to iterate over the contents of the map.boolean
remove
(int id) This method may be used to remove the score for the specified ID.int
size()
This method returns the number of id's present in the array.toString()
This method returns a fancy string containing some info about this array.
-
Constructor Details
-
IDScoreMap
public IDScoreMap(int maxSize) Constructs the map with the maximum size.- Parameters:
maxSize
- The maximum size of the map.
-
-
Method Details
-
add
Add the score to the array. This operation might cause the internal size to be expanded (but no more than max-size). The scores are stored internally in a sorted order, with the highest score at the front of the array. This method return an Integer with the id of the item that was removed from this list by adding the new id, or null if nothing was removed. If you wish to known if the id was really added you should check the size before and after the add in combination with the id that is returned.
for example:
int oldSize = list.size();
boolean added = list.add( ... ) != null || oldSize > list.size();
- Parameters:
id
- The id that should be added to the array.score
- The score belonging to the id.- Returns:
- integer containing the id that wass removed.
-
remove
public boolean remove(int id) This method may be used to remove the score for the specified ID.- Parameters:
id
- The ID whose score should be removed.- Returns:
- Boolean indicating if a score was actually removed.
-
clear
public void clear()Removes all items from the array by resetting the size to zero. -
contains
public boolean contains(int id) This method returns a boolean indicating if a score is present for the specified ID.- Parameters:
id
- The ID for which should be checked if a score is available.- Returns:
- a boolean indicating if a score is present for the specified ID.
-
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.
-
iterator
This method returns an iterator that may be used to iterate over the contents of the map.- Returns:
- an iterator that may be used to iterate over the contents of the map.
-
isEmpty
public boolean isEmpty()This method returns true if the array is empty, false otherwise.- Returns:
- true if the array is empty, false otherwise.
-
isFull
public boolean isFull()This method returns true if the array is filled with the maximum amount of scores, false otherwise.- Returns:
- true if the array is filled with the maximum amount of scores, false otherwise.
-
getHighestScore
public int getHighestScore()This method returns the highest score that is present in the map.- Returns:
- the highest score that is present in the map.
-
getLowestScore
public int getLowestScore()This method returns the lowest score that is present in the map.- Returns:
- the lowest score that is present in the map.
-
getMaximumSize
public int getMaximumSize()This method returns the maximum size the map may reach.- Returns:
- the maximum size the map may reach.
-
toString
This method returns a fancy string containing some info about this array.
-