public class ObjectCollectionWithProperties extends Object implements Iterable<ObjectWithProperties>
ObjectCollection
but each object has associated properties.
Like a ObjectCollection
, it is backed internally by an ArrayList
, offering add
operations in constant time, and other operations in linear-time.
Constructor and Description |
---|
ObjectCollectionWithProperties(int capacity)
Create with zero objects.
|
ObjectCollectionWithProperties(ObjectCollection objects)
Create with a stream of objects, assign empty properties to each.
|
ObjectCollectionWithProperties(ObjectMask object)
Create with a single object.
|
ObjectCollectionWithProperties(java.util.stream.Stream<ObjectWithProperties> objects)
Create with a stream of objects with properties.
|
Modifier and Type | Method and Description |
---|---|
void |
add(ObjectMask object)
Add an
ObjectMask to the collection, assigning empty properties to it. |
void |
add(ObjectWithProperties object)
Add an
ObjectWithProperties to the collection. |
ObjectWithProperties |
get(int index)
Get an item at a particular index.
|
boolean |
isEmpty()
Whether the number of objects is zero.
|
Iterator<ObjectWithProperties> |
iterator() |
int |
size()
Number of objects in the collection.
|
String |
toString() |
ObjectCollection |
withoutProperties()
Returns the contained-objects without the corresponding properties.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
public ObjectCollectionWithProperties(int capacity)
capacity
- the capacity of the internally created list.public ObjectCollectionWithProperties(ObjectMask object)
object
- the object.public ObjectCollectionWithProperties(java.util.stream.Stream<ObjectWithProperties> objects)
objects
- the objects.public ObjectCollectionWithProperties(ObjectCollection objects)
objects
- the objects.public void add(ObjectMask object)
ObjectMask
to the collection, assigning empty properties to it.object
- the object.public void add(ObjectWithProperties object)
ObjectWithProperties
to the collection.object
- the object.public ObjectWithProperties get(int index)
index
- the index.public Iterator<ObjectWithProperties> iterator()
iterator
in interface Iterable<ObjectWithProperties>
public ObjectCollection withoutProperties()
This is an immutable operation.
ObjectCollection
containing the same objects as the
current collection, but without any associated properties.public int size()
public boolean isEmpty()
Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.