|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Interface that represents sets of entities.
A Population
is a set of instances of
Entity
or a subclass.
A Population
instance is obtained originally by invoking
on an createPopulation
Entity
.
The membership of a Population
can be refined by creating a new
instance, using the methods
applyFilter
, join
, or rejectFilter
.
An Entity
can wait for the state of a Population
to
change by using the Trigger
instances returned by the methods
becomesEmpty
, excludes
, includes
,
sizeBelow
, or sizeExceeds
.
A Population
will never contain a null
member.
A Population
will never contain duplicate members.
The membership of a Population
will not change unless an Entity
either
Entity
that meets the membership criteria for the
Population
Filter
Copyright © 2003-2004 The MITRE Corporation
Method Summary | |
Population |
applyFilter(Filter filter)
Create new filtered Population . |
Trigger |
becomesEmpty()
Trigger for Population being empty. |
boolean |
contains(Entity e)
Returns true if this |
Trigger |
excludes(Entity entity)
Trigger when Entity not a member. |
Trigger |
includes(Entity entity)
Trigger when Entity is a member. |
boolean |
isEmpty()
Returns true if this Population contains no members. |
java.util.Iterator |
iterator()
Returns an iterator over the members in this Population . |
Population |
join(Population pop)
Create new combination Population . |
Population |
rejectFilter(Filter filter)
Create new filtered Population . |
int |
size()
Returns the number of members in this Population . |
Trigger |
sizeBelow(int threshold)
Trigger on Population size. |
Trigger |
sizeExceeds(int threshold)
Trigger on Population size. |
Entity[] |
toArray()
Returns an array containing all the members in this Population . |
Method Detail |
public Population applyFilter(Filter filter)
Population
.
Create new Population
instance whose members are all the members of
the current instance for which the filter
returns true
.
filter
- Developer-supplied instance of Filter
implementation
Population
public Trigger becomesEmpty()
Trigger
for Population
being empty.
Create Trigger
whose
condition
returns true
when the size of the current Population
is zero.
Trigger
public boolean contains(Entity e)
true
if this true
if and only if this elt
such that elt.equals(e)
.
(Note that Entity
does not override equals()
.)
e
- Entity
whose membership is to be tested
true
if e
is member of current instancepublic Trigger excludes(Entity entity)
Trigger
when Entity
not a member.
Create Trigger
whose
condition
returns true
when entity
is not a member of the current Population
.
entity
- Entity
to be excluded
Trigger
public Trigger includes(Entity entity)
Trigger
when Entity
is a member.
Create Trigger
whose
condition
returns true
when entity
is a member of the current Population
.
entity
- Entity
to be included
Trigger
public boolean isEmpty()
true
if this Population
contains no members.
true
if this Population
contains no memberspublic java.util.Iterator iterator()
Population
.
There are no guarantees concerning the order in which the members are returned.
The behavior of the iterator is undefined if the Entity takes any action while
holding an Iterator
returned by this method that might change
the membership of the Population
.
Iterator
over the members of this Population
public Population join(Population pop)
Population
.
Create new Population
instance whose members are all the members of
the current instance and all the members of pop
.
Like all instances of Population
, the new instance contains no
duplicates.
Population
public Population rejectFilter(Filter filter)
Population
.
Create new Population
instance whose members are all the members of
the current instance for which the filter
returns false
.
filter
- Developer-supplied instance of Filter
implementation
Population
public int size()
Population
.
If this Population
contains more than Integer.MAX_VALUE
members,
returns Integer.MAX_VALUE
.
Population
public Trigger sizeBelow(int threshold)
Trigger
on Population
size.
Create Trigger
whose
condition
returns true
when the size of the current Population
is less than threshold
.
threshold
- size below which Trigger
is true
Trigger
public Trigger sizeExceeds(int threshold)
Trigger
on Population
size.
Create Trigger
whose
condition
returns true
when the size of the current Population
is greater than threshold
.
threshold
- size above which Trigger
is true
Trigger
public Entity[] toArray()
Population
.
There are no guarantees as to the order of the array elements.
The caller is free to modify the returned array.
If the membership of the Population
changes after this call returns,
the array is not modified.
Thus the array is a snapshot of the membership at the time of the call.
Population
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |