net.sourceforge.cilib.entity.topologies
Class GBestTopology<E extends Entity>

java.lang.Object
  extended by net.sourceforge.cilib.entity.AbstractTopology<E>
      extended by net.sourceforge.cilib.entity.topologies.GBestTopology<E>
Type Parameters:
E - The Entity type.
All Implemented Interfaces:
Serializable, Iterable<E>, Collection<E>, List<E>, Topology<E>, Cloneable
Direct Known Subclasses:
HypercubeTopology, LBestTopology

public class GBestTopology<E extends Entity>
extends AbstractTopology<E>

Implementation of the gbest neighbourhood topology.

References:

Author:
Edwin Peer
See Also:
Serialized Form

Nested Class Summary
protected static interface GBestTopology.IndexedIterator<T extends Entity>
          Interface to define the manner in which the iterator is to be constructed for Array types.
 
Field Summary
protected  LinkedList<E> entities
           
 
Constructor Summary
GBestTopology()
          Creates a new instance of GBestTopology.
GBestTopology(GBestTopology<E> copy)
           
 
Method Summary
 boolean add(E particle)
          Adds an entity to the topology.
 void add(int index, E element)
           
 boolean addAll(Collection<? extends E> set)
           
 boolean addAll(int index, Collection<? extends E> c)
           
 List<E> asList()
          Get all the entities within the topology.
 void clear()
          Remove all the entities from the topology.
 boolean contains(Object entity)
          
 boolean containsAll(Collection<?> c)
          
 boolean equals(Object o)
          
 E get(int index)
          
 GBestTopology<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()
          
 int indexOf(Object o)
           
 boolean isEmpty()
          
 Iterator<E> iterator()
          
 int lastIndexOf(Object o)
           
 ListIterator<E> listIterator()
           
 ListIterator<E> listIterator(int index)
           
 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 indiv)
          Removes an entity from the topology.
 E remove(int index)
           
 boolean remove(Object o)
          
 boolean removeAll(Collection<?> c)
          
 boolean retainAll(Collection<?> c)
          
 E set(int index, E particle)
          
 void setId(String id)
          Set the id for this Topology.
 int size()
          Returns the size of the Topology.
 List<E> subList(int fromIndex, int toIndex)
           
 Object[] toArray()
          
<T> T[]
toArray(T[] a)
          
 
Methods inherited from class net.sourceforge.cilib.entity.AbstractTopology
accept, accept, clearBestEntity, getBestEntity, getBestEntity, update
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

entities

protected LinkedList<E extends Entity> entities
Constructor Detail

GBestTopology

public GBestTopology()
Creates a new instance of GBestTopology.


GBestTopology

public GBestTopology(GBestTopology<E> copy)
Method Detail

getClone

public GBestTopology<E> getClone()
Description copied from class: AbstractTopology
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 Topology<E extends Entity>
Specified by:
getClone in interface Cloneable
Specified by:
getClone in class AbstractTopology<E extends Entity>
Returns:
An exact clone of the current object instance.
See Also:
Object.clone()

iterator

public Iterator<E> iterator()
Description copied from interface: Topology


neighbourhood

public Iterator<E> neighbourhood(Iterator<? extends Entity> iterator)
Description copied from interface: Topology
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.

add

public boolean add(E particle)
Description copied from interface: Topology
Adds an entity to the topology.

Parameters:
particle - The entity to be added.
Returns:
true if the addition is successful, false otherwise.

addAll

public boolean addAll(Collection<? extends E> set)

size

public int size()
Description copied from interface: Topology
Returns the size of the Topology.

Returns:
The size of Topology.

remove

public boolean remove(E indiv)
Description copied from interface: Topology
Removes an entity from the topology.

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

get

public E get(int index)
Description copied from interface: Topology


set

public E set(int index,
             E particle)
Description copied from interface: Topology


asList

public List<E> asList()
Description copied from interface: Topology
Get all the entities within the topology.

Returns:
Collection. Data collection of all the entities

isEmpty

public boolean isEmpty()
Description copied from interface: Topology


clear

public void clear()
Description copied from interface: Topology
Remove all the entities from the topology.


contains

public boolean contains(Object entity)
Description copied from interface: Topology


containsAll

public boolean containsAll(Collection<?> c)
Description copied from interface: Topology


equals

public boolean equals(Object o)
Description copied from interface: Topology

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

hashCode

public int hashCode()
Description copied from interface: Topology

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

remove

public boolean remove(Object o)
Description copied from interface: Topology


removeAll

public boolean removeAll(Collection<?> c)
Description copied from interface: Topology


retainAll

public boolean retainAll(Collection<?> c)
Description copied from interface: Topology


toArray

public Object[] toArray()
Description copied from interface: Topology


toArray

public <T> T[] toArray(T[] a)
Description copied from interface: Topology


addAll

public boolean addAll(int index,
                      Collection<? extends E> c)

add

public void add(int index,
                E element)

remove

public E remove(int index)

indexOf

public int indexOf(Object o)

lastIndexOf

public int lastIndexOf(Object o)

listIterator

public ListIterator<E> listIterator()

listIterator

public ListIterator<E> listIterator(int index)

subList

public List<E> subList(int fromIndex,
                       int toIndex)

getId

public String getId()
Description copied from interface: Topology
Get the id associated with this Topology, if an id is defined.

Returns:
The id for this Topology.

setId

public void setId(String id)
Description copied from interface: Topology
Set the id for this Topology.

Parameters:
id - The value to set.


Copyright © 2009 CIRG. All Rights Reserved.