org.limewire.collection
Class IntervalSet.ByteIntervals
java.lang.Object
org.limewire.collection.IntervalSet.ByteIntervals
- Enclosing class:
- IntervalSet
public static class IntervalSet.ByteIntervals
- extends java.lang.Object
Allows you to keep int and long intervals in the same
location. Lets you know how many bytes are needed to represent the set
of ranges.
try{
IntervalSet set = new IntervalSet();
set.add(Range.createRange(55, 58));
set.add(Range.createRange(90, 97));
set.add(Range.createRange(3, 7));
set.add(Range.createRange(52, 53));
set.add(Range.createRange(28, 33));
set.add(Range.createRange(60, 73));
IntervalSet.ByteIntervals asByte = set.toBytes();
System.out.println("Length of set = " + set.getSize()
+ " and interval as a list " + set.getAllIntervalsAsList() );
//A length of zero means there haven't been any longs added to the set yet.
System.out.println("Length of asByte's long =" + asByte.longs.length);
//create a long range
set.add(Range.createRange(0xFFFFFFFFF0l, 0xFFFFFFFFFFl));
asByte = set.toBytes();
System.out.println("New length of asByte's long ="
+ asByte.longs.length);
System.out.println("Length of asByte=" + asByte.length() );
//Now there will be one one long range from
//3 until 0xFFFFFFFFFFl (size: 10)
set.add(Range.createRange(3, 0xFFFFFFFFFFl));
asByte = set.toBytes();
System.out.println("Length of set= " + set.getSize()
+ " and interval as a list " + set.getAllIntervalsAsList() );
System.out.println("Length of asByte=" + asByte.length() );
}
catch(Exception e){
e.printStackTrace();
}
Output:
Length of set = 39 and interval as a list [3-7, 28-33, 52-53, 55-58, 60-73, 90-97]
Length of asByte's long =0
New length of asByte's long =10
Length of asByte=58
Length of set= 1099511627773 and interval as a list [3-1099511627775]
Length of asByte=10
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ints
public final byte[] ints
longs
public final byte[] longs
length
public int length()
Copyright © 2009 Lime Wire LLC. All Rights Reserved.