Class: ABM.BreedSet
Defined in: | src/breed_set.coffee |
Inherits: | ABM.Set |
Direct Known Subclasses
ABM.Agents ABM.Links ABM.Patches
Variables Summary
- _push =
-
Keeps a copy of push for our use.
Instance Method Summary
- # (void) create() Abstract method used by subclasses to create and add their instances.
- # (void) push(object...) Pushes an agent to the list.
- # (void) remove(object) Remove an agent from the agentset, returning the agentset.
- # (void) pop()
- # (void) reBreed(agent) Move an agent from its BreedSet to be in this BreedSet.
Inherited Method Summary
Methods inherited from
ABM.Set
.from #setDefault #exclude #draw #show #hide #inRadius #inCone #toFixed #any #empty #clear #clone #first #last #select #reject #sample #contains #remove #removeItem #shuffle #min #max #sum #average #median #histogram #sort #uniq #flatten #concat #normalize #normalizeInt #ask #with #getProperty #setProperty #other
Constructor Details
#
(void)
constructor(agentClass, name, mainSet)
Create an empty Set
and initialize the ID
counter for push().
If mainSet is supplied, the new agentset is a sub-array of mainSet.
This sub-array feature is how breeds are managed, see class Model
.
Instance Method Details
#
(void)
create()
Abstract method used by subclasses to create and add their instances.
#
(void)
push(object...)
Pushes an agent to the list. Only used by agentset factory
methods. Adds the id
property to all agents and increments it.
Returns the object for chaining.
By "agent" we mean an instance of Patch
, Agent
and Link
and their breeds.
#
(void)
remove(object)
Remove an agent from the agentset, returning the agentset. Note this does not change delete id or change the set's ID, thus an agentset can have gaps in terms of their id's.
AS.remove(AS[3]) # [{id: 0, x: 0, y: 1}, {id: 1, x: 8, y: 0},
{id: 2, x: 6, y: 4}, {id: 4, x: 1, y: 1}]
#
(void)
pop()
#
(void)
reBreed(agent)
Move an agent from its BreedSet to be in this BreedSet.