com.limegroup.gnutella.util
Class IntervalSet

java.lang.Object
  extended bycom.limegroup.gnutella.util.IntervalSet

public class IntervalSet
extends java.lang.Object

A "range" version of IntSet. This is a first cut of the class and does not support all the operations IntSet does, just the ones we need for now.

Important Note: This class uses Interval from the download package. Ideally, classes in the util package should be stand alone, but we need to have Interval stay in downloads for reasons of backward compatibility.


Constructor Summary
IntervalSet()
           
 
Method Summary
 void add(Interval addInterval)
           
 void clear()
           
 java.util.Iterator getAllIntervals()
           
 java.util.List getAllIntervalsAsList()
           
 java.util.Iterator getNeededIntervals(int maxSize)
           
 java.util.List getOverlapIntervals(Interval checkInterval)
           
 int getSize()
           
 boolean isEmpty()
           
 Interval removeFirst()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IntervalSet

public IntervalSet()
Method Detail

add

public void add(Interval addInterval)

removeFirst

public Interval removeFirst()

getOverlapIntervals

public java.util.List getOverlapIntervals(Interval checkInterval)
Returns:
a List of intervals that overlap checkInterval. For example if Intervals contains{[1-4],[6-10]} and checkInterval is [3-8], this method should return a list of 2 intervals {[3-4],[6-8]} If there are no overlaps, this method returns an empty List.

getAllIntervals

public java.util.Iterator getAllIntervals()

getAllIntervalsAsList

public java.util.List getAllIntervalsAsList()

getSize

public int getSize()

isEmpty

public boolean isEmpty()

clear

public void clear()

getNeededIntervals

public java.util.Iterator getNeededIntervals(int maxSize)
Returns:
an iterator or intervals needed to fill in the holes in this IntervalSet. Note that the IntervalSet does not know the maximum value of all the intervals.

toString

public java.lang.String toString()