Class IDObjectMap

java.lang.Object
com.aquima.interactions.matching.util.IDObjectMap
All Implemented Interfaces:
Serializable

public final class IDObjectMap extends Object implements 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 Classes
    Modifier and Type
    Class
    Description
    static final class 
    Iterator class that can be used to iterate over the contents of an IDObjectMap class.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs the map with an initial size of zero.
    IDObjectMap(int initialSize)
    Constructs the map with an initial size.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    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
    This method returns true if the array is empty, false otherwise.
    This method returns an iterator that can be used to iterate over the contents of the map.
    boolean
    put(int id, Object objValue)
    Add the id to the array.
    remove(int id)
    Remove the given id from the array.
    int
    This method returns the number of id's present in the array.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • IDObjectMap

      public IDObjectMap()
      Constructs the map with an initial size of zero.
    • IDObjectMap

      public IDObjectMap(int initialSize)
      Constructs the map with an initial size.
      Parameters:
      initialSize - The initial size of the map.
  • Method Details

    • put

      public boolean put(int id, Object objValue)
      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

      public Object remove(int id)
      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

      public Object get(int id)
      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

      public IDObjectMap.ObjectIterator 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

      public String toString()
      Overrides:
      toString in class Object