com.faunos.skwish.sys.mgr
Class PrecedenceComparator

java.lang.Object
  extended by com.faunos.skwish.sys.mgr.PrecedenceComparator
All Implemented Interfaces:
Comparator<Segment>

public class PrecedenceComparator
extends Object
implements Comparator<Segment>

A comparator used by the collector to prune overridden (and therefore dead) segments. The aim is to order dead and live segments as in the diagram below.

                     XXXX
                   ~X
                  ~XX
               XXXXXX
            ~XX
        ~XXXX
     ~0
      XXXXXXXXX
 
The horizontal axis represents entry IDs, and each block of X's represents a segment spanning a range of IDs. Dead segments ignored by the collector are marked with a leading '~' above (understood not to contribute to the segment's range). An empty segment is represented as an '0'.

Under the operational invariants maintained by the collector, then, this ordering has the following property: a segment may only be covered by a preceding segment.

Author:
Babak Farhang
See Also:
UnitDir.Seg.covers(com.faunos.skwish.sys.mgr.UnitDir.Seg)

Field Summary
static Comparator<Segment> INSTANCE
           
 
Constructor Summary
PrecedenceComparator()
           
 
Method Summary
 int compare(Segment s1, Segment s2)
          Compares the two given segments, firstly by their base IDs, secondly by which has more entries.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Field Detail

INSTANCE

public static final Comparator<Segment> INSTANCE
Constructor Detail

PrecedenceComparator

public PrecedenceComparator()
Method Detail

compare

public int compare(Segment s1,
                   Segment s2)
Compares the two given segments, firstly by their base IDs, secondly by which has more entries.

Specified by:
compare in interface Comparator<Segment>


SourceForge.net Logo