net.sourceforge.cilib.entity
Interface Topology<E extends Entity>

Type Parameters:
E - All types derived from Entity.
All Superinterfaces:
Cloneable, Collection<E>, Iterable<E>, List<E>, Serializable
All Known Implementing Classes:
AbstractTopology, GBestTopology, HypercubeTopology, LBestTopology, VonNeumannTopology

public interface Topology<E extends Entity>
extends Iterable<E>, List<E>, Cloneable, Serializable

This is a generalization for all algorithms that maintain a collection of Entity objects. Examples of this would include PSO, EC and ACO.

Author:
Gary Pampara

Method Summary
 void accept(TopologyVisitor visitor)
          Accept a TopologyVisitor into the Topology to perform the actions defined within the TopologyVisitor.
 void accept(Visitor<E> visitor)
          Accept a vistitor and perform the visitor actions on this Topology.
 boolean add(E entity)
          Adds an entity to the topology.
 List<E> asList()
          Get all the entities within the topology.
 void clear()
          Remove all the entities from the topology.
 void clearBestEntity()
          Clear the current best entity from the topology, thereby forcing a re-calculation of the best Entity within the topology.
 boolean contains(Object o)
          
 boolean containsAll(Collection<?> c)
          
 boolean equals(Object o)
          
 E get(int index)
          
 E getBestEntity()
          Obtain the current best entity within the Topology.
 E getBestEntity(Comparator<? super E> comparator)
          Obtain the current best entity within the Topology, based on the provided Comparator.
 Topology<E> getClone()
          Create a cloned copy of the current object and return it.
 String getId()
          Get the id associated with this Topology, if an id is defined.
 int hashCode()
          
 boolean isEmpty()
          
 Iterator<E> iterator()
          
 Iterator<E> neighbourhood(Iterator<? extends Entity> iterator)
          Returns an Iterator over all particles in the neighbourhood of the particle referred to by the given Iterator.
 boolean remove(E entity)
          Removes an entity from the topology.
 boolean remove(Object o)
          
 boolean removeAll(Collection<?> c)
          
 boolean retainAll(Collection<?> c)
          
 E set(int index, E entity)
          
 void setId(String id)
          Set the id for this Topology.
 int size()
          Returns the size of the Topology.
 Object[] toArray()
          
<T> T[]
toArray(T[] a)
          
 void update()
          Perform any required updates to the Topology instance.
 
Methods inherited from interface java.util.List
add, addAll, addAll, indexOf, lastIndexOf, listIterator, listIterator, remove, subList
 

Method Detail

getClone

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

add

boolean add(E entity)
Adds an entity to the topology.

Specified by:
add in interface Collection<E extends Entity>
Specified by:
add in interface List<E extends Entity>
Parameters:
entity - The entity to be added.
Returns:
true if the addition is successful, false otherwise.

remove

boolean remove(E entity)
Removes an entity from the topology.

Parameters:
entity - The entity to be removed.
Returns:
boolean, true if remove operation was successful.

get

E get(int index)

Specified by:
get in interface List<E extends Entity>

set

E set(int index,
      E entity)

Specified by:
set in interface List<E extends Entity>

isEmpty

boolean isEmpty()

Specified by:
isEmpty in interface Collection<E extends Entity>
Specified by:
isEmpty in interface List<E extends Entity>

clear

void clear()
Remove all the entities from the topology.

Specified by:
clear in interface Collection<E extends Entity>
Specified by:
clear in interface List<E extends Entity>

contains

boolean contains(Object o)

Specified by:
contains in interface Collection<E extends Entity>
Specified by:
contains in interface List<E extends Entity>

containsAll

boolean containsAll(Collection<?> c)

Specified by:
containsAll in interface Collection<E extends Entity>
Specified by:
containsAll in interface List<E extends Entity>

equals

boolean equals(Object o)

Specified by:
equals in interface Collection<E extends Entity>
Specified by:
equals in interface List<E extends Entity>
Overrides:
equals in class Object

hashCode

int hashCode()

Specified by:
hashCode in interface Collection<E extends Entity>
Specified by:
hashCode in interface List<E extends Entity>
Overrides:
hashCode in class Object

iterator

Iterator<E> iterator()

Specified by:
iterator in interface Collection<E extends Entity>
Specified by:
iterator in interface Iterable<E extends Entity>
Specified by:
iterator in interface List<E extends Entity>

remove

boolean remove(Object o)

Specified by:
remove in interface Collection<E extends Entity>
Specified by:
remove in interface List<E extends Entity>

removeAll

boolean removeAll(Collection<?> c)

Specified by:
removeAll in interface Collection<E extends Entity>
Specified by:
removeAll in interface List<E extends Entity>

retainAll

boolean retainAll(Collection<?> c)

Specified by:
retainAll in interface Collection<E extends Entity>
Specified by:
retainAll in interface List<E extends Entity>

size

int size()
Returns the size of the Topology.

Specified by:
size in interface Collection<E extends Entity>
Specified by:
size in interface List<E extends Entity>
Returns:
The size of Topology.

toArray

Object[] toArray()

Specified by:
toArray in interface Collection<E extends Entity>
Specified by:
toArray in interface List<E extends Entity>

toArray

<T> T[] toArray(T[] a)

Specified by:
toArray in interface Collection<E extends Entity>
Specified by:
toArray in interface List<E extends Entity>

getId

String getId()
Get the id associated with this Topology, if an id is defined.

Returns:
The id for this Topology.

setId

void setId(String id)
Set the id for this Topology.

Parameters:
id - The value to set.

asList

List<E> asList()
Get all the entities within the topology.

Returns:
Collection. Data collection of all the entities

getBestEntity

E getBestEntity()
Obtain the current best entity within the Topology.

Returns:
The best Entity.

getBestEntity

E getBestEntity(Comparator<? super E> comparator)
Obtain the current best entity within the Topology, based on the provided Comparator.

Parameters:
comparator - The Comparator to use.
Returns:
The best Entity based on the defined comparison.

accept

void accept(Visitor<E> visitor)
Accept a vistitor and perform the visitor actions on this Topology.

Parameters:
visitor - The Visitor to accept

accept

void accept(TopologyVisitor visitor)
Accept a TopologyVisitor into the Topology to perform the actions defined within the TopologyVisitor.

Parameters:
visitor - The instance to accept into the Topology.

update

void update()
Perform any required updates to the Topology instance. The method in has an empty implementation and needs to be overridden within the required subclass.


neighbourhood

Iterator<E> neighbourhood(Iterator<? extends Entity> iterator)
Returns an Iterator over all particles in the neighbourhood of the particle referred to by the given Iterator.

Parameters:
iterator - An iterator that refers to a particle in this topology.
Returns:
A particle iterator.

clearBestEntity

void clearBestEntity()
Clear the current best entity from the topology, thereby forcing a re-calculation of the best Entity within the topology.



Copyright © 2009 CIRG. All Rights Reserved.