org.archive.wayback.util.partition
Class Partition<T>

java.lang.Object
  extended by org.archive.wayback.util.partition.Partition<T>
Type Parameters:
T - Generic type which this partition holds.

public class Partition<T>
extends Object

A class which holds elements of some type for a particular Date range. This class also has two additional application-usable fields: containsClosest: boolean - tracks whether this Partition holds the "closest" element of interest to an application total: int - independent counter for total internal application-level elements, useful when nesting partitions, to track the sum-of-totals of interior partitions

Author:
brad

Constructor Summary
Partition(Date start, Date end)
          Create a Partition for holding elements between the two argument Date objects.
 
Method Summary
 void add(T o)
           
 void addTotal(int numberToAdd)
          Add and int to the Total count for this partition.
 boolean containsDate(Date d)
          Checks if a date is within this partition
 int count()
           
 Date getEnd()
           
 Date getStart()
           
 int getTotal()
           
 boolean isContainsClosest()
           
 Iterator<T> iterator()
           
 List<T> list()
           
 void setContainsClosest(boolean containsClosest)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Partition

public Partition(Date start,
                 Date end)
Create a Partition for holding elements between the two argument Date objects.

Parameters:
start - Date representing the start of elements held in this Partition, inclusive.
end - Date representing the end of elements held in this Partition, exclusive.
Method Detail

containsDate

public boolean containsDate(Date d)
Checks if a date is within this partition

Parameters:
d - Date to check
Returns:
boolean true if d is >= start, and < end

getStart

public Date getStart()
Returns:
the start Date for this Partition.

getEnd

public Date getEnd()
Returns:
the end Date for this Partition.

count

public int count()
Returns:
number of elements held in this Partition.

add

public void add(T o)
Parameters:
o - element to be added to this partition.

iterator

public Iterator<T> iterator()
Returns:
an Iterator of elements held in this Partition.

list

public List<T> list()
Returns:
a List of the elements held in this Partition.

isContainsClosest

public boolean isContainsClosest()
Returns:
the containsClosest

setContainsClosest

public void setContainsClosest(boolean containsClosest)
Parameters:
containsClosest - the containsClosest to set

addTotal

public void addTotal(int numberToAdd)
Add and int to the Total count for this partition.

Parameters:
numberToAdd - number to add

getTotal

public int getTotal()
Returns:
the Total count for this partition.


Copyright © 2005-2011 Internet Archive. All Rights Reserved.