net.sourceforge.cilib.util.selection.weighing
Class FixedWeighing<E>

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

public class FixedWeighing<E>
extends Object
implements Weighing<E>

Apply a fixed weighing to a list of elements.

Author:
Wiehann Matthysen
See Also:
Serialized Form

Constructor Summary
FixedWeighing()
          Create a new instance with the default weighing value of 0.0.
FixedWeighing(double weight)
          Create a new instance with the provided value for weighing.
FixedWeighing(FixedWeighing<E> copy)
          Create a copy of the provided instance.
 
Method Summary
 FixedWeighing<E> getClone()
          Create a cloned copy of the current object and return it.
 double getWeight()
          Get the weight value.
 void setWeight(double weight)
          Set the weight value.
 boolean weigh(List<Selection.Entry<E>> elements)
          Perform a weighing on the provided list of entries.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FixedWeighing

public FixedWeighing()
Create a new instance with the default weighing value of 0.0.


FixedWeighing

public FixedWeighing(double weight)
Create a new instance with the provided value for weighing.

Parameters:
weight - The weighing value to use.

FixedWeighing

public FixedWeighing(FixedWeighing<E> copy)
Create a copy of the provided instance.

Parameters:
copy - The instance to copy.
Method Detail

getClone

public FixedWeighing<E> 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 Weighing<E>
Returns:
An exact clone of the current object instance.
See Also:
Object.clone()

setWeight

public void setWeight(double weight)
Set the weight value.

Parameters:
weight - The value to set.

getWeight

public double getWeight()
Get the weight value.

Returns:

weigh

public boolean weigh(List<Selection.Entry<E>> elements)
Perform a weighing on the provided list of entries. Apply the defined weight value to the all the entries contain in elements.

Specified by:
weigh in interface Weighing<E>
Parameters:
elements - The entries to weigh.
Returns:
true if successful, false otherwise.


Copyright © 2009 CIRG. All Rights Reserved.