net.sourceforge.cilib.util.selection.ordering
Class RingBasedOrdering<E>

java.lang.Object
  extended by net.sourceforge.cilib.util.selection.ordering.RingBasedOrdering<E>
Type Parameters:
E - The selection type.
All Implemented Interfaces:
Ordering<E>

public class RingBasedOrdering<E>
extends Object
implements Ordering<E>

Arrange all elements as a ring and depending on the desired pivot point, return an ordering that defines the list of elements that follow on from the pivot.

Author:
Wiehann Matthysen

Constructor Summary
RingBasedOrdering()
          Create a new instance.
RingBasedOrdering(E marker)
          Create a new instance with the provided marker as the pivot point.
 
Method Summary
 boolean order(List<Selection.Entry<E>> elements)
          Apply the ordering on the provided list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RingBasedOrdering

public RingBasedOrdering()
Create a new instance. The defined marker or pivot point is null.


RingBasedOrdering

public RingBasedOrdering(E marker)
Create a new instance with the provided marker as the pivot point.

Parameters:
marker - The pivot point to use.
Method Detail

order

public boolean order(List<Selection.Entry<E>> elements)
Apply the ordering on the provided list.

The application of this ordering will result in "next in line" ordering, based on the currently provided marker.

Example:
If the set of integers, {1, 2, 3, 4, 5, 6, 7, 8, 9}, is ordered with the marker element defined to be 5, the resulting order will be: {6, 7, 8, 9, 1, 2, 3, 4, 5}

Specified by:
order in interface Ordering<E>
Parameters:
elements - The list to be ordered.
Returns:
true if successful, false otherwise.


Copyright © 2009 CIRG. All Rights Reserved.