com.netflix.nfgraph.compressed
Class BitSetOrdinalSet

java.lang.Object
  extended by com.netflix.nfgraph.OrdinalSet
      extended by com.netflix.nfgraph.compressed.BitSetOrdinalSet

public class BitSetOrdinalSet
extends OrdinalSet

An implementation of OrdinalSet, returned for connections represented as a bit set in an NFCompressedGraph.

A bit set representation contains a single bit per ordinal in the type to which the connections point. If the bit at the position for a given ordinal is set, then there is a connection to that ordinal in this set.

Because determining membership in a set requires only checking whether the bit at a given position is set, contains() is an O(1) operation.

This representation will automatically be chosen for a set by the NFCompressedGraphBuilder when it requires fewer bytes than the configured representation (either NFPropertySpec.COMPACT or NFPropertySpec.HASH).

See Also:
Compact Representations

Field Summary
 
Fields inherited from class com.netflix.nfgraph.OrdinalSet
EMPTY_SET
 
Constructor Summary
BitSetOrdinalSet(com.netflix.nfgraph.util.ByteArrayReader reader)
           
 
Method Summary
 boolean contains(int value)
          Returns true when the specified value is contained in this set.
 OrdinalIterator iterator()
           
 int size()
           
 
Methods inherited from class com.netflix.nfgraph.OrdinalSet
asArray, containsAll
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitSetOrdinalSet

public BitSetOrdinalSet(com.netflix.nfgraph.util.ByteArrayReader reader)
Method Detail

contains

public boolean contains(int value)
Description copied from class: OrdinalSet
Returns true when the specified value is contained in this set. Depending on the implementation, this operation will have one of two performance characteristics:

O(1) for HashSetOrdinalSet and BitSetOrdinalSet
O(n) for CompactOrdinalSet and NFBuildGraphOrdinalSet

Specified by:
contains in class OrdinalSet

iterator

public OrdinalIterator iterator()
Specified by:
iterator in class OrdinalSet
Returns:
an OrdinalIterator over this set.

size

public int size()
Specified by:
size in class OrdinalSet
Returns:
the number of ordinals in this set.