healpix.core.base.set
Class LongRangeSetBuilder

java.lang.Object
  extended by healpix.core.base.set.LongRangeSetBuilder

public class LongRangeSetBuilder
extends Object

Builder for LongRangeSet . LongRangeSet is unmodifiable, this class is 'factory' to create new instances.

To keep it fast and simple, this fab only supports appending. Uour ranges must be already sorted. This work for most of Healpix based operations.

LongRangeSet can also be constructed using LongSet

Author:
Jan Kotek

Field Summary
static LongRangeSet EMPTY
          empty LongRangeSet
 
Constructor Summary
LongRangeSetBuilder()
           
LongRangeSetBuilder(int arraySize)
          construct new builder with given array size
 
Method Summary
 void append(long first)
          append single long into builder
 void appendRange(long first, long last)
          append range into builder
 void appendRanges(LongRangeIterator iter)
          appends all ranges from iterator
 void appendRangeSet(LongRangeSet set)
          append all ranges from given LongRangeSet
 LongRangeSet build()
          Construct new LongRangeSet from appended values *
 void ensureSize(int arraySize)
          make sure underling array have at least given size
static LongRangeSet readFrom(DataInput in)
          Read LongRangeSet from an input stream
 int size()
           
static void writeTo(DataOutput out, LongRangeSet rs)
          Write LongRangeSet into stream in an space efficient way.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY

public static final LongRangeSet EMPTY
empty LongRangeSet

Constructor Detail

LongRangeSetBuilder

public LongRangeSetBuilder()

LongRangeSetBuilder

public LongRangeSetBuilder(int arraySize)
construct new builder with given array size

Parameters:
arraySize -
Method Detail

ensureSize

public void ensureSize(int arraySize)
make sure underling array have at least given size


append

public void append(long first)
append single long into builder

Parameters:
first - - long to append

appendRange

public void appendRange(long first,
                        long last)
append range into builder

Parameters:
first - long in range (inclusive)
last - long in range(inclusive)

appendRanges

public void appendRanges(LongRangeIterator iter)
appends all ranges from iterator

Parameters:
iter - LongRangeIterator

appendRangeSet

public void appendRangeSet(LongRangeSet set)
append all ranges from given LongRangeSet

Parameters:
set - LongRangeSet to append

size

public int size()
Returns:
number of added ranges so far

build

public LongRangeSet build()
Construct new LongRangeSet from appended values *

Returns:
LongRangeSet with appended values

writeTo

public static void writeTo(DataOutput out,
                           LongRangeSet rs)
                    throws IOException
Write LongRangeSet into stream in an space efficient way. Delta compression is used and Longs are stored in packed form.

Parameters:
out -
rs -
Throws:
IOException

readFrom

public static LongRangeSet readFrom(DataInput in)
                             throws IOException
Read LongRangeSet from an input stream

Parameters:
in -
Returns:
the new LongRangeSet
Throws:
IOException

"Built from revision exported"