ChromAb
Class CycleRecord

java.lang.Object
  |
  +--ChromAb.CycleRecord

public class CycleRecord
extends java.lang.Object

Keeps an ordered list of cycles and counts the number of occurances. Cycles stored in decreasing order.


Nested Class Summary
private  class CycleRecord.Entry
          Private class that stores an entry in the Cycle record.
 
Field Summary
private  java.util.Vector record
           
 
Constructor Summary
CycleRecord()
           
 
Method Summary
 boolean add(Cycle cycle)
          Method to add a cycle to the cycle record.
 int countAt(int index)
          Returns the number of cycles at the specified index
 Cycle cycleAt(int index)
          Returns the cycle at the specified index.
 java.lang.String displayWithPercent()
          Returns a String which lists the cycles in the record with percentages of total
private  CycleRecord.Entry entryAt(int index)
          Returns the Entry object (private to this class) for the specified index.
private  void incrementCount(int index)
          Increments the counter of the entry at the specified index.
 Cycle obligate()
          Returns the obligate cycle in the record.
 java.lang.String toString()
           
 int totalNumberOfCycles()
          Returns the total number of cycles in the record.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

record

private java.util.Vector record
Constructor Detail

CycleRecord

public CycleRecord()
Method Detail

add

public boolean add(Cycle cycle)
Method to add a cycle to the cycle record. It returns true if the cycle was already in the record, false if it has to create a new entry. If the cycle is already in the record, its count is incremented by one.

Parameters:
cycle - cycle to add to record
Returns:
true if already in record, false otherwise.

entryAt

private CycleRecord.Entry entryAt(int index)
Returns the Entry object (private to this class) for the specified index.

Parameters:
index - index value
Returns:
Entry entry at index.

cycleAt

public Cycle cycleAt(int index)
Returns the cycle at the specified index.

Parameters:
index - index value
Returns:
Cycle at index

countAt

public int countAt(int index)
Returns the number of cycles at the specified index

Parameters:
index - index value
Returns:
count at index

incrementCount

private void incrementCount(int index)
Increments the counter of the entry at the specified index.

Parameters:
index - index value

obligate

public Cycle obligate()
Returns the obligate cycle in the record. This is the last entry in the list.

Returns:
"lowest" cycle in the record.

toString

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

totalNumberOfCycles

public int totalNumberOfCycles()
Returns the total number of cycles in the record.

Returns:
total number of cycles in the record.

displayWithPercent

public java.lang.String displayWithPercent()
Returns a String which lists the cycles in the record with percentages of total

Returns:
String to display the cycle record with percentages of total