Interface KeyedSet<K,V>

All Superinterfaces:
Collection<V>, Iterable<V>, Set<V>
All Known Implementing Classes:
LinkedHashKeyedSet

public interface KeyedSet<K,V> extends Set<V>
A KeyedSet is a set whose members have distinct keys and can be looked up by key. A Keyer provides keys for the elements. It is forbidden for an element's key to change while the element is in the set.
  • Field Details

  • Method Details

    • getKeyer

      Keyer<? extends K,? super V> getKeyer()
      Returns the Keyer that this KeyedSet uses to obtain keys for elements.
      Returns:
      the Keyer that this KeyedSet uses to obtain keys for elements
    • add

      V add(V v, int conflictBehavior, int equalBehavior)
      Adds v to this KeyedSet; this set's Keyer will be called once to fetch v's key. If an object equal to v is already present in this KeyedSet, then this method carries out the equalBehavior and returns the existing object. Otherwise, if an object having a key equal to v's is already present in this KeyedSet, then this method carries out the conflictBehavior and returns the existing object. Otherwise, this method adds v to this KeyedSet and returns null.
      Parameters:
      v - the object to be added
      conflictBehavior - specifies what to do if v's key equals an existing object's key
      equalBehavior - specifies what to do if v equals an existing object
      Returns:
      the existing object whose key matched v's, if any
    • replace

      V replace(V v)
      Adds v to this KeyedSet, replacing and returning an existing object with the same key as v (if any). The existing object is replaced with v even if it equals v. If no existing object is replaced, null is returned.
    • lookup

      V lookup(K k)
      Looks for and returns an element with key k, or null if none.
      Returns:
      the element with key k, or null if none