public class SignalCollection extends Object implements Collection<Signal>
Constructor and Description |
---|
SignalCollection()
Create a new empty instance.
|
SignalCollection(Collection<Signal> signals)
Create a new instance which consists of a set of signals.
|
SignalCollection(Iterable<? extends SignalCollection> signalCollections)
Create a new instance based on combining an existing set of signal collections.
|
SignalCollection(Signal... signals)
Create a new instance which consists of the provided signals.
|
SignalCollection(Signal signal)
Create a new instance which consists of a single signal.
|
SignalCollection(SignalCollection... signals)
Create a new instance based on combining an existing set of signal collections.
|
SignalCollection(SignalCollection existingInstance)
Initializes a new instance as a copy of an existing instance.
|
Modifier and Type | Method and Description |
---|---|
boolean |
__remove(Signal item) |
boolean |
add(Signal item)
Ensures that this collection contains the specified element (optional
operation).
|
boolean |
addAll(Collection<? extends Signal> c)
Adds all of the elements in the specified collection to this collection
(optional operation).
|
SignalCollection |
addNoiseTemperature(double noiseTemperature)
Creates a new collection of signals by increasing the noise temperature for each signal.
|
SignalCollection |
addSignals(Iterable<? extends Signal> signals)
Creates a new
SignalCollection by adding signals. |
SignalCollection |
addSignals(Signal... signals)
Creates a new
SignalCollection by adding signals. |
SignalCollection |
applyFrequencyShift(double frequencyShiftFactor)
Create a new composite signal by shifting the frequency of the constituents of this signal.
|
SignalCollection |
applyGain(double gain)
Create a new composite signal by applying a gain to this composite signal.
|
void |
clear()
Removes all of the elements from this collection (optional operation).
|
double |
computeTotalPower()
Computes the total sum of the power of the individual signals.
|
boolean |
contains(Object item)
Search to determine whether the given signal is an element of the composite signal.
|
boolean |
containsAll(Collection<?> c)
Returns true if this collection contains all of the elements
in the specified collection.
|
void |
copyTo(Signal[] array,
int arrayIndex)
Copy the constituent signals to the given array, starting at the given index.
|
boolean |
equals(Object obj)
Indicates whether another object is exactly equal to this instance.
|
boolean |
equals(SignalCollection other)
Indicates whether this collection of signals is equivalent to another collection of signals.
|
Signal |
find(Predicate<Signal> match)
Searches for a signal that matches the conditions defined by the specified
predicate, and returns the first occurrence within the collection.
|
Signal |
get(int index)
Gets the constituent signal at the given index.
|
int |
hashCode()
Returns a hash code for this instance, which is suitable for use in hashing algorithms and data structures like a hash table.
|
int |
indexOf(Signal signal)
Searches for the specified signal and returns the zero-based index of the
first occurrence within the collection.
|
boolean |
isEmpty()
Returns true if this collection contains no elements.
|
Iterator<Signal> |
iterator()
Get an enumerator for the signals in the collections.
|
SignalCollection |
modifySignals(double gain,
double frequencyShiftFactor)
Create a new composite signal by uniformly modifying the power and frequency of the existing constituent signals.
|
SignalCollection |
modifySignals(SignalModificationMethod changeSignal)
Create a new composite signal by modifying the existing constituent signals and removing any which are
null.
|
SignalCollection |
modifySignalsWithoutRemoval(SignalModificationMethod changeSignal)
Create a new composite signal by modifying the existing constituent signals.
|
boolean |
remove(Object item)
Removes a single instance of the specified element from this
collection, if it is present (optional operation).
|
boolean |
removeAll(Collection<?> c)
Removes all of this collection's elements that are also contained in the
specified collection (optional operation).
|
SignalCollection |
removeSignals(Predicate<Signal> match)
Creates a new
SignalCollection by removing signals based on a predicate. |
boolean |
retainAll(Collection<?> c)
Retains only the elements in this collection that are contained in the
specified collection (optional operation).
|
SignalCollection |
selectSignals(Predicate<Signal> match)
Creates a new
SignalCollection by selecting signals based on a predicate. |
int |
size()
Gets the number of constituent signals in the composite signal.
|
Object[] |
toArray()
Returns an array containing all of the elements in this collection.
|
<T> T[] |
toArray(T[] a)
Returns an array containing all of the elements in this collection;
the runtime type of the returned array is that of the specified array.
|
boolean |
trueForAll(Predicate<Signal> match)
Determines whether every signal in the collection
matches the conditions defined by the specified predicate.
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
parallelStream, removeIf, spliterator, stream
public SignalCollection()
public SignalCollection(@Nonnull SignalCollection existingInstance)
existingInstance
- The existing instance to copy.ArgumentNullException
- Thrown when existingInstance
is null
.public SignalCollection(@Nonnull Signal signal)
signal
- The single signal.ArgumentNullException
- Thrown when signal
is null
.public SignalCollection(@Nonnull Collection<Signal> signals)
signals
- The set of signals contained in this composite.ArgumentNullException
- Thrown when signals
is null
,
or when any of the contained signals is null
.public SignalCollection(@Nonnull Signal... signals)
signals
- The parameterized array of signals contained in this composite.public SignalCollection(@Nonnull SignalCollection... signals)
signals
- The set of signals contained in this composite.public SignalCollection(@Nonnull Iterable<? extends SignalCollection> signalCollections)
signalCollections
- The existing signal collections to combine.ArgumentNullException
- Thrown when signalCollections
is null
,
or when any item in signalCollections
is null
.@Nonnull public final SignalCollection addSignals(@Nonnull Signal... signals)
SignalCollection
by adding signals.signals
- A set of signals to add.ArgumentNullException
- Thrown when signals
is null
,
or when any of the contained signals is null
.@Nonnull public final SignalCollection addSignals(@Nonnull Iterable<? extends Signal> signals)
SignalCollection
by adding signals.signals
- A set of signals to add.ArgumentNullException
- Thrown when signals
is null
,
or when any of the contained signals is null
.@Nonnull public final SignalCollection removeSignals(@Nonnull Predicate<Signal> match)
SignalCollection
by removing signals based on a predicate.match
- A delegate defining the conditions on a Signal
which will remove it from the new collection.ArgumentNullException
- Thrown when match
is null
.@Nonnull public final SignalCollection selectSignals(@Nonnull Predicate<Signal> match)
SignalCollection
by selecting signals based on a predicate.match
- A delegate defining the conditions on a Signal
which will add it to the new collection.ArgumentNullException
- Thrown when match
is null
.@Nonnull public final SignalCollection applyGain(double gain)
gain
- The gain to apply to all constituent signals in this composite signal.@Nonnull public final SignalCollection applyFrequencyShift(double frequencyShiftFactor)
The new frequency is the old frequency multiplied by the shift factor.
frequencyShiftFactor
- The multiplicative frequency shift to apply to all constituent signals in this signal.@Nonnull public final SignalCollection modifySignals(double gain, double frequencyShiftFactor)
gain
- The gain to apply to the power of each signal.frequencyShiftFactor
- The multiplicative frequency shift to apply to each signal.@Nonnull public final SignalCollection modifySignals(@Nonnull SignalModificationMethod changeSignal)
changeSignal
- A user-defined method to modify each of the constituent signals. If the
modification method returns null for a given signal, that signal will be removed.@Nonnull public final SignalCollection modifySignalsWithoutRemoval(@Nonnull SignalModificationMethod changeSignal)
This method is slightly faster than SignalCollection.modifySignals(SignalModificationMethod)
since this
does not have to check for null
.
changeSignal
- A user-defined method to modify each of the constituent signals.@Nonnull public final SignalCollection addNoiseTemperature(double noiseTemperature)
noiseTemperature
- The noise temperature to add, in kelvin.public final double computeTotalPower()
public final Iterator<Signal> iterator()
public final boolean contains(Object item)
contains
in interface Collection<Signal>
item
- The signal for which to search.true
if the signal is part of the composite; otherwise false
.public final void copyTo(Signal[] array, int arrayIndex)
array
- The one-dimensional, zero-indexed array which is the destination of the copy.arrayIndex
- The zero-indexed index at which to start the copy.ArgumentNullException
- array is null.ArgumentOutOfRangeException
- arrayIndex
is less than zero.ArgumentException
- array
is multidimensional.-or-arrayIndex
is equal to or greater than the
length of array
.-or-The number of elements in the source Collection
is greater than the available space from arrayIndex
to the end of the destination
array
.-or-Type T cannot be cast automatically to the type of the destination
array
.public final int size()
size
in interface Collection<Signal>
@Nonnull public final Signal get(int index)
index
- The index of the signal to retrieve.ArgumentOutOfRangeException
- Thrown when the index
is less than zero or not less than Count
(get
).public final int indexOf(Signal signal)
signal
- The signal to locate in the collection.@Nonnull public final Signal find(@Nonnull Predicate<Signal> match)
match
- The delegate that defines the conditions of the signal to search for.BaseSignal
(get
).public final boolean trueForAll(@Nonnull Predicate<Signal> match)
match
- The delegate defining the conditions to check against.true
if every signal in the collection matches the
conditions defined by the specified predicate, or if the list has no elements; otherwise false
.public final boolean add(Signal item)
java.util.Collection
Collections that support this operation may place limitations on what elements may be added to this collection. In particular, some collections will refuse to add null elements, and others will impose restrictions on the type of elements that may be added. Collection classes should clearly specify in their documentation any restrictions on what elements may be added.
If a collection refuses to add a particular element for any reason other than that it already contains the element, it must throw an exception (rather than returning false). This preserves the invariant that a collection always contains the specified element after this call returns.
add
in interface Collection<Signal>
item
- element whose presence in this collection is to be ensuredpublic final void clear()
java.util.Collection
clear
in interface Collection<Signal>
public final boolean remove(Object item)
java.util.Collection
remove
in interface Collection<Signal>
item
- element to be removed from this collection, if presentpublic final boolean __remove(Signal item)
public boolean equals(Object obj)
equals
in interface Collection<Signal>
equals
in class Object
obj
- The object to compare to this instance.true
if obj
is an instance of this type and represents the same value as this instance; otherwise false
.Object.hashCode()
,
HashMap
public final boolean equals(SignalCollection other)
other
- The other collection of signals.true
if each of the signals in other
is
equal to the corresponding signal in this collection; otherwise false
.public int hashCode()
hashCode
in interface Collection<Signal>
hashCode
in class Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
public final boolean isEmpty()
java.util.Collection
isEmpty
in interface Collection<Signal>
public final boolean addAll(Collection<? extends Signal> c)
java.util.Collection
addAll
in interface Collection<Signal>
c
- collection containing elements to be added to this collectionCollection.add(Object)
public final boolean containsAll(Collection<?> c)
java.util.Collection
containsAll
in interface Collection<Signal>
c
- collection to be checked for containment in this collectionCollection.contains(Object)
public final Object[] toArray()
java.util.Collection
The returned array will be "safe" in that no references to it are maintained by this collection. (In other words, this method must allocate a new array even if this collection is backed by an array). The caller is thus free to modify the returned array.
This method acts as bridge between array-based and collection-based APIs.
toArray
in interface Collection<Signal>
public final <T> T[] toArray(T[] a)
java.util.Collection
If this collection fits in the specified array with room to spare (i.e., the array has more elements than this collection), the element in the array immediately following the end of the collection is set to null. (This is useful in determining the length of this collection only if the caller knows that this collection does not contain any null elements.)
If this collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.
Like the Collection.toArray()
method, this method acts as bridge between
array-based and collection-based APIs. Further, this method allows
precise control over the runtime type of the output array, and may,
under certain circumstances, be used to save allocation costs.
Suppose x is a collection known to contain only strings. The following code can be used to dump the collection into a newly allocated array of String:
String[] y = x.toArray(new String[0]);Note that toArray(new Object[0]) is identical in function to toArray().
toArray
in interface Collection<Signal>
T
- the runtime type of the array to contain the collectiona
- the array into which the elements of this collection are to be
stored, if it is big enough; otherwise, a new array of the same
runtime type is allocated for this purpose.public final boolean removeAll(Collection<?> c)
java.util.Collection
removeAll
in interface Collection<Signal>
c
- collection containing elements to be removed from this collectionCollection.remove(Object)
,
Collection.contains(Object)
public final boolean retainAll(Collection<?> c)
java.util.Collection
retainAll
in interface Collection<Signal>
c
- collection containing elements to be retained in this collectionCollection.remove(Object)
,
Collection.contains(Object)