org.tranche.hash.span
Class HashSpan

java.lang.Object
  extended by org.tranche.hash.span.HashSpan
All Implemented Interfaces:
java.lang.Comparable<HashSpan>
Direct Known Subclasses:
AbstractHashSpan

public class HashSpan
extends java.lang.Object
implements java.lang.Comparable<HashSpan>

Represents a range of hashes.

Author:
Jayson Falkner - jfalkner@umich.edu, James "Augie" Hill - augman85@gmail.com

Field Summary
static BigHash FIRST
          Constant of the first and last possible BigHash possible.
static HashSpan FULL
          Full hash span
static java.util.Set<HashSpan> FULL_SET
           
static BigHash LAST
          Constant of the first and last possible BigHash possible.
 
Constructor Summary
HashSpan(BigHash first, BigHash last)
           
 
Method Summary
 HashSpan clone()
          Return a cloned copy of this HashSpan object.
 int compareTo(HashSpan hs)
          Compare the equality (first hash) of another HashSpan.
 boolean contains(BigHash hash)
          Returns true if has is between the first and last hashes in hash span range.
 boolean equals(java.lang.Object o)
          Returns true if two hash spans are the same; false otherwise.
 BigHash getFirst()
          Retrieve first BigHash portion of HashSpan.
 BigHash getLast()
          Retrieve last BigHash portion of HashSpan.
 int hashCode()
          Return the hash code of the HashSpan.
 boolean isAdjecentTo(HashSpan hashSpan)
          Whether the given hash span has an end BigHash that comes immediately before or after this HashSpan.
 boolean overlaps(HashSpan hashSpan)
          Whether any BigHash in the given HashSpan is also in this HashSpan.
 void setFirst(BigHash first)
          Set first BigHash portion of the HashSpan.
 void setLast(BigHash last)
          Set last BigHash portion of the HashSpan.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

FIRST

public static final BigHash FIRST

Constant of the first and last possible BigHash possible.


LAST

public static final BigHash LAST

Constant of the first and last possible BigHash possible.


FULL

public static final HashSpan FULL

Full hash span


FULL_SET

public static final java.util.Set<HashSpan> FULL_SET
Constructor Detail

HashSpan

public HashSpan(BigHash first,
                BigHash last)
Parameters:
first -
last -
Method Detail

getFirst

public BigHash getFirst()
Retrieve first BigHash portion of HashSpan.

Returns:

setFirst

public void setFirst(BigHash first)
Set first BigHash portion of the HashSpan.

Parameters:
first -

getLast

public BigHash getLast()
Retrieve last BigHash portion of HashSpan.

Returns:

setLast

public void setLast(BigHash last)
Set last BigHash portion of the HashSpan.

Parameters:
last -

compareTo

public int compareTo(HashSpan hs)
Compare the equality (first hash) of another HashSpan. Returns 0 if equal; anything else otherwise.

Specified by:
compareTo in interface java.lang.Comparable<HashSpan>
Parameters:
hs -
Returns:

contains

public boolean contains(BigHash hash)
Returns true if has is between the first and last hashes in hash span range.

Parameters:
hash - BigHash wish to check if in this hash span
Returns:
boolean true if in range, false if not

overlaps

public boolean overlaps(HashSpan hashSpan)

Whether any BigHash in the given HashSpan is also in this HashSpan.

Parameters:
hashSpan -
Returns:

isAdjecentTo

public boolean isAdjecentTo(HashSpan hashSpan)

Whether the given hash span has an end BigHash that comes immediately before or after this HashSpan.

Parameters:
hashSpan -
Returns:

hashCode

public int hashCode()
Return the hash code of the HashSpan.

Overrides:
hashCode in class java.lang.Object
Returns:

equals

public boolean equals(java.lang.Object o)
Returns true if two hash spans are the same; false otherwise.

Overrides:
equals in class java.lang.Object
Parameters:
o - hash span
Returns:
boolean true if same, false otherwise

clone

public HashSpan clone()
Return a cloned copy of this HashSpan object.

Overrides:
clone in class java.lang.Object
Returns:

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:


This code is free for use both commercially and non-commercially as stated in the project's license