net.sourceforge.cilib.util.selection.recipes
Class ElitistSelection<E extends Comparable>

java.lang.Object
  extended by net.sourceforge.cilib.util.selection.recipes.ElitistSelection<E>
Type Parameters:
E - The selection type.
All Implemented Interfaces:
Serializable, Cloneable, SelectionRecipe<E>

public class ElitistSelection<E extends Comparable>
extends Object
implements SelectionRecipe<E>

A recipe for Elitist selection.

Elitist selection is performed by:

  1. Sorting the list of elements in a natural ordering.
  2. Selecting the last element from the list as it is the "best".
  3. Return the result.

Author:
Wiehann Matthysen
See Also:
Serialized Form

Constructor Summary
ElitistSelection()
          Create a new instance with a defined comparator being DefaultComparator.
ElitistSelection(Comparator<Selection.Entry<E>> comparator)
          Create a new instance with the provided Comparator.
ElitistSelection(ElitistSelection copy)
          Create a copy of the provided instance.
 
Method Summary
 ElitistSelection getClone()
          Create a cloned copy of the current object and return it.
 Comparator<Selection.Entry<E>> getComparator()
          Get the current comparator.
 E select(List<? extends E> elements)
          Perform the selection process.
 void setComparator(Comparator<Selection.Entry<E>> comparator)
          Set the comparator to be used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ElitistSelection

public ElitistSelection()
Create a new instance with a defined comparator being DefaultComparator.


ElitistSelection

public ElitistSelection(Comparator<Selection.Entry<E>> comparator)
Create a new instance with the provided Comparator.

Parameters:
comparator - The comparator to set.

ElitistSelection

public ElitistSelection(ElitistSelection copy)
Create a copy of the provided instance.

Parameters:
copy - The instance to copy.
Method Detail

getClone

public ElitistSelection getClone()
Create a cloned copy of the current object and return it. In general the created copy will be a deep copy of the provided instance. As a result this operation an be quite expensive if used incorrectly.

Specified by:
getClone in interface Cloneable
Specified by:
getClone in interface SelectionRecipe<E extends Comparable>
Returns:
An exact clone of the current object instance.
See Also:
Object.clone()

setComparator

public void setComparator(Comparator<Selection.Entry<E>> comparator)
Set the comparator to be used.

Parameters:
comparator - The value to set.

getComparator

public Comparator<Selection.Entry<E>> getComparator()
Get the current comparator.

Returns:
The current comparator instance.

select

public E select(List<? extends E> elements)
Perform the selection process.

Specified by:
select in interface SelectionRecipe<E extends Comparable>
Parameters:
elements - The elements to perfrom the selection on.
Returns:
The selected element.


Copyright © 2009 CIRG. All Rights Reserved.