Package org.moeaframework.parallel.util
Class ImmigrationQueue
java.lang.Object
org.moeaframework.parallel.util.ImmigrationQueue
A queue for tracking migrating solutions that is (1) thread-safe, and (2) automatically creates copies of the
solutions to avoid issues in shared-memory environments.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a copy of the solution to this immigration queue.void
addAll
(Collection<? extends Solution> solutions) Adds a copy of all solutions to this immigration queue.void
Adds a copy of all solutions to this immigration queue.boolean
isEmpty()
Returnstrue
if this immigration queue is empty.pop()
Removes and returns one solution from this immigration queue.popAll()
Removes and returns all solutions currently in the immigration queue.int
size()
Returns the number of solutions in the immigration queue
-
Constructor Details
-
ImmigrationQueue
public ImmigrationQueue()Creates a new, empty immigration queue.
-
-
Method Details
-
add
Adds a copy of the solution to this immigration queue.- Parameters:
solution
- the solution to add
-
addAll
Adds a copy of all solutions to this immigration queue.- Parameters:
solutions
- the solutions to add
-
addAll
Adds a copy of all solutions to this immigration queue.- Parameters:
solutions
- the solutions to add
-
pop
Removes and returns one solution from this immigration queue.- Returns:
- the solution that was removed
-
popAll
Removes and returns all solutions currently in the immigration queue.- Returns:
- the solutions that were removed
-
size
public int size()Returns the number of solutions in the immigration queue- Returns:
- the number of solutions
-
isEmpty
public boolean isEmpty()Returnstrue
if this immigration queue is empty.- Returns:
true
if empty;false
otherwise
-