org.apache.mahout.math.set
Class AbstractLongSet

java.lang.Object
  extended by org.apache.mahout.math.PersistentObject
      extended by org.apache.mahout.math.set.AbstractSet
          extended by org.apache.mahout.math.set.AbstractLongSet
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
OpenLongHashSet

public abstract class AbstractLongSet
extends AbstractSet

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.mahout.math.set.AbstractSet
DEFAULT_CAPACITY, DEFAULT_MAX_LOAD_FACTOR, DEFAULT_MIN_LOAD_FACTOR, distinct, highWaterMark, lowWaterMark, maxLoadFactor, minLoadFactor
 
Constructor Summary
AbstractLongSet()
           
 
Method Summary
abstract  boolean add(long key)
          Associates the given key with the given value.
 boolean contains(long key)
          Returns true if the receiver contains the specified key.
 AbstractLongSet copy()
          Returns a deep copy of the receiver; uses clone() and casts the result.
 boolean equals(Object obj)
           
abstract  boolean forEachKey(LongProcedure procedure)
          Applies a procedure to each key of the receiver, if any.
 int hashCode()
           
 LongArrayList keys()
          Returns a list filled with all keys contained in the receiver.
 void keys(LongArrayList list)
          Fills all keys contained in the receiver into the specified list.
abstract  boolean remove(long key)
          Removes the given key with its associated element from the receiver, if present.
 String toString()
          Returns a string representation of the receiver, containing the String representation of each key-value pair, sorted ascending by key.
 
Methods inherited from class org.apache.mahout.math.set.AbstractSet
chooseGrowCapacity, chooseHighWaterMark, chooseLowWaterMark, chooseMeanCapacity, chooseShrinkCapacity, clear, ensureCapacity, equalsMindTheNull, isEmpty, nextPrime, setUp, size, trimToSize
 
Methods inherited from class org.apache.mahout.math.PersistentObject
clone
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractLongSet

public AbstractLongSet()
Method Detail

contains

public boolean contains(long key)
Returns true if the receiver contains the specified key.

Returns:
true if the receiver contains the specified key.

copy

public AbstractLongSet copy()
Returns a deep copy of the receiver; uses clone() and casts the result.

Returns:
a deep copy of the receiver.

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

forEachKey

public abstract boolean forEachKey(LongProcedure procedure)
Applies a procedure to each key of the receiver, if any. Note: Iterates over the keys in no particular order. Subclasses can define a particular order, for example, "sorted by key". All methods which can be expressed in terms of this method (most methods can) must guarantee to use the same order defined by this method, even if it is no particular order. This is necessary so that, for example, methods keys and values will yield association pairs, not two uncorrelated lists.

Parameters:
procedure - the procedure to be applied. Stops iteration if the procedure returns false, otherwise continues.
Returns:
false if the procedure stopped before all keys where iterated over, true otherwise.

keys

public LongArrayList keys()
Returns a list filled with all keys contained in the receiver. The returned list has a size that equals this.size(). Iteration order is guaranteed to be identical to the order used by method forEachKey(LongProcedure).

This method can be used to iterate over the keys of the receiver.

Returns:
the keys.

keys

public void keys(LongArrayList list)
Fills all keys contained in the receiver into the specified list. Fills the list, starting at index 0. After this call returns the specified list has a new size that equals this.size(). Iteration order is guaranteed to be identical to the order used by method forEachKey(LongProcedure).

This method can be used to iterate over the keys of the receiver.

Parameters:
list - the list to be filled, can have any size.

add

public abstract boolean add(long key)
Associates the given key with the given value. Replaces any old (key,someOtherValue) association, if existing.

Parameters:
key - the key the value shall be associated with.
Returns:
true if the receiver did not already contain such a key; false if the receiver did already contain such a key - the new value has now replaced the formerly associated value.

remove

public abstract boolean remove(long key)
Removes the given key with its associated element from the receiver, if present.

Parameters:
key - the key to be removed from the receiver.
Returns:
true if the receiver contained the specified key, false otherwise.

toString

public String toString()
Returns a string representation of the receiver, containing the String representation of each key-value pair, sorted ascending by key.

Overrides:
toString in class Object


Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.