uk.ac.leeds.ccg.andyt.grids.utilities
Class UnsignedLong

java.lang.Object
  extended by uk.ac.leeds.ccg.andyt.grids.utilities.UnsignedLong

public class UnsignedLong
extends java.lang.Object

A 64 bit number representing the natural numbers from 0 to 2 raised to the power of 64. NB. It can be better to use a look up to a Powersof2 instance or set of them rather than calculate them on the fly.


Constructor Summary
UnsignedLong()
          Constructs a newly allocated UnsignedLong object that represents the default long 0L.
UnsignedLong(boolean[] binaryEncoding)
          Constructs a newly allocated UnsignedLong object that represents a long binary encoded by the specified boolean[] argument.
UnsignedLong(long value)
          Constructs a newly allocated UnsignedLong object that represents the specified long argument.
 
Method Summary
 byte getCount()
          Returns a count of the number of values of 1 in the binary encoding of value.
 long getLong()
          Returns this.value.
 boolean isAtPosition(int position)
          Returns true if the value of long as a binary encoding has a value of 1 at position.
 void setLong(long value)
          Sets this.value to value.
 java.lang.String toBinaryString()
          Returns the value of long as a binary encoded String.
 boolean[] toBooleanArray()
          Returns this.value as a binary encoded boolean[].
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UnsignedLong

public UnsignedLong()
Constructs a newly allocated UnsignedLong object that represents the default long 0L.


UnsignedLong

public UnsignedLong(long value)
Constructs a newly allocated UnsignedLong object that represents the specified long argument.

Parameters:
value - The value to be represented by this.

UnsignedLong

public UnsignedLong(boolean[] binaryEncoding)
Constructs a newly allocated UnsignedLong object that represents a long binary encoded by the specified boolean[] argument.

Parameters:
binaryEncoding - The binary encoding of the long value to be represented by the UnsignedLong object.
Method Detail

getLong

public long getLong()
Returns this.value.


setLong

public void setLong(long value)
Sets this.value to value.

Parameters:
value - The value this.value is set to.

toBooleanArray

public boolean[] toBooleanArray()
Returns this.value as a binary encoded boolean[].


isAtPosition

public boolean isAtPosition(int position)
Returns true if the value of long as a binary encoding has a value of 1 at position.


toBinaryString

public java.lang.String toBinaryString()
Returns the value of long as a binary encoded String.


getCount

public byte getCount()
Returns a count of the number of values of 1 in the binary encoding of value.