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

java.lang.Object
  extended by net.sourceforge.cilib.entity.AbstractTopology<E>
      extended by net.sourceforge.cilib.entity.topologies.VonNeumannTopology<E>
Type Parameters:
E - A Entity instance.
All Implemented Interfaces:
Serializable, Iterable<E>, Collection<E>, List<E>, Topology<E>, Cloneable

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

Implementation of the Von Neumann neighbourhood topology. The Von Neumann topology is a two dimensional grid of particles with wrap around.

Refereces:

Author:
Edwin Peer, Gary Pampara
See Also:
Serialized Form

Constructor Summary
VonNeumannTopology()
          Creates a new instance of VonNeumannTopology.
VonNeumannTopology(VonNeumannTopology<E> copy)
          Copy constructor.
 
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 o)
          
 boolean containsAll(Collection<?> c)
          
 boolean equals(Object o)
          
 E get(int index)
          
 VonNeumannTopology<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 indiv)
          
 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
 

Constructor Detail

VonNeumannTopology

public VonNeumannTopology()
Creates a new instance of VonNeumannTopology.


VonNeumannTopology

public VonNeumannTopology(VonNeumannTopology<E> copy)
Copy constructor. Create a copy of the provided instance.

Parameters:
copy - The instance to copy.
Method Detail

getClone

public VonNeumannTopology<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 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()

neighbourhood

public 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.

iterator

public Iterator<E> iterator()


add

public boolean add(E particle)
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()
Returns the size of the Topology.

Returns:
The size of Topology.

remove

public boolean remove(E indiv)
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)


set

public E set(int index,
             E indiv)


asList

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

Returns:
Collection. Data collection of all the entities

isEmpty

public boolean isEmpty()


clear

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


contains

public boolean contains(Object o)


containsAll

public boolean containsAll(Collection<?> c)


equals

public boolean equals(Object o)

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()

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)


removeAll

public boolean removeAll(Collection<?> c)


retainAll

public boolean retainAll(Collection<?> c)


toArray

public Object[] toArray()


toArray

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


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()
Get the id associated with this Topology, if an id is defined.

Returns:
The id for this Topology.

setId

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

Parameters:
id - The value to set.


Copyright © 2009 CIRG. All Rights Reserved.