Package PamguardMVC
Class PamDataUnitIterator<E extends PamDataUnit>
java.lang.Object
PamguardMVC.PamDataUnitIterator<E>
- Type Parameters:
E
-
- All Implemented Interfaces:
Iterator<E>
,ListIterator<E>
- Direct Known Subclasses:
ChannelIterator
,SequenceIterator
public abstract class PamDataUnitIterator<E extends PamDataUnit>
extends Object
implements ListIterator<E>
An iterator that has a bit more functionality than a basic iterator.
It's main enhancement is to use a channel map match to PamDataUnits, so that it only returns data units that have an overlap in channels with the given channel map (which could be 0xFFFFFFFF).
It also has a couple of extra searches to getPreceeding() and getFollowing() data units.
It's main enhancement is to use a channel map match to PamDataUnits, so that it only returns data units that have an overlap in channels with the given channel map (which could be 0xFFFFFFFF).
It also has a couple of extra searches to getPreceeding() and getFollowing() data units.
- Author:
- Doug Gillespie
-
Constructor Summary
ConstructorDescriptionPamDataUnitIterator
(PamDataBlock<E> pamDataBlock, int chanOrSeqMap, int whereFrom) An iterator that has a bit more functionality than a basic iterator. -
Method Summary
Modifier and TypeMethodDescriptionvoid
int
Return the channel or sequence map specified during object instantiationgetClosest
(long timeMilliseconds, boolean firstOrlastOk) Get the unit closest to the given time.abstract E
getFirstUnit
(int chanOrSeqMap) Get the first unit for a specific channel or sequence map (any match of channels allowed).getFollowing
(long timeMilliseconds, boolean lastOk) Get the unit immediately following or at the given time.abstract E
getLastUnit
(int chanOrSeqMap) Get the last unit for a specific channel or sequence map (any match of channels allowed).getPreceding
(long timeMilliseconds, boolean firstOk) Get the unit immediately before or at the given time.boolean
hasNext()
boolean
abstract E
next()
Return the next PamDataUnit, or null if there is no 'next' PamDataUnitint
abstract E
previous()
Return the previous PamDataUnit, or null if there is no 'previous' PamDataUnitint
void
remove()
void
void
setSynchObject
(Object synchObject) Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
PamDataUnitIterator
An iterator that has a bit more functionality than a basic iterator.
It's main enhancement is to use a channel map match to PamDataUnits, so that it only returns data units that have an overlap in channels with the given channel map (which could be 0xFFFFFFFF).
It also has a couple of extra searches to getPreceeding() and getFollowing() data units.- Parameters:
pamDataBlock
- Datablock containing the datachanOrSeqMap
- channel map (requires overlap, ot exact match)whereFrom
- start at beginning or end. 0 = beginning; -1 (or PamDatablock.ITERATOR_END) for the end
-
-
Method Details
-
getFirstUnit
Get the first unit for a specific channel or sequence map (any match of channels allowed).- Parameters:
chanOrSeqMap
- channel/sequence map- Returns:
- first data unit with at least one channel matching, or null.
-
getLastUnit
Get the last unit for a specific channel or sequence map (any match of channels allowed).- Parameters:
chanOrSeqMap
- channel/sequence map- Returns:
- last data unit with at least one channel matching, or null.
-
next
Return the next PamDataUnit, or null if there is no 'next' PamDataUnit- Specified by:
next
in interfaceIterator<E extends PamDataUnit>
- Specified by:
next
in interfaceListIterator<E extends PamDataUnit>
-
previous
Return the previous PamDataUnit, or null if there is no 'previous' PamDataUnit- Specified by:
previous
in interfaceListIterator<E extends PamDataUnit>
-
hasNext
public boolean hasNext()- Specified by:
hasNext
in interfaceIterator<E extends PamDataUnit>
- Specified by:
hasNext
in interfaceListIterator<E extends PamDataUnit>
-
hasPrevious
public boolean hasPrevious()- Specified by:
hasPrevious
in interfaceListIterator<E extends PamDataUnit>
-
getPreceding
Get the unit immediately before or at the given time.- Parameters:
timeMilliseconds
- time in milliseconds.firstOk
- if this is true and no unit precedes the given time, it will return the first unit, otherwise it will return null- Returns:
- a data unit, or null.
-
getFollowing
Get the unit immediately following or at the given time.- Parameters:
timeMilliseconds
- time in milliseconds.lastOk
- if this is true and no unit precedes the given time, it will return the last unit, otherwise it will return null- Returns:
- a data unit, or null.
-
getClosest
Get the unit closest to the given time.- Parameters:
timeMilliseconds
- time in milliseconds.firstOrlastOk
- if this is true and no unit precedes the given time, it will return the last unit, otherwise it will return null- Returns:
- a data unit, or null.
-
nextIndex
public int nextIndex()- Specified by:
nextIndex
in interfaceListIterator<E extends PamDataUnit>
-
previousIndex
public int previousIndex()- Specified by:
previousIndex
in interfaceListIterator<E extends PamDataUnit>
-
remove
public void remove()- Specified by:
remove
in interfaceIterator<E extends PamDataUnit>
- Specified by:
remove
in interfaceListIterator<E extends PamDataUnit>
-
set
- Specified by:
set
in interfaceListIterator<E extends PamDataUnit>
-
add
- Specified by:
add
in interfaceListIterator<E extends PamDataUnit>
-
getChanOrSeqMap
public int getChanOrSeqMap()Return the channel or sequence map specified during object instantiation- Returns:
- the channel/sequence Map
-
getPamDataBlock
- Returns:
- the pamDataBlock
-
getSynchObject
- Returns:
- the synchObject
-
setSynchObject
- Parameters:
synchObject
- the synchObject to set
-