TAdvancingIterator
, TIterator
public interface TObjectByteIterator<K> extends TAdvancingIterator
// accessing keys/values through an iterator: for ( TObjectByteIterator it = map.iterator(); it.hasNext(); ) { it.advance(); if ( satisfiesCondition( it.key() ) ) { doSomethingWithValue( it.value() ); } }
// modifying values in-place through iteration: for ( TObjectByteIterator it = map.iterator(); it.hasNext(); ) { it.advance(); if ( satisfiesCondition( it.key() ) ) { it.setValue( newValueForKey( it.key() ) ); } }
// deleting entries during iteration: for ( TObjectByteIterator it = map.iterator(); it.hasNext(); ) { it.advance(); if ( satisfiesCondition( it.key() ) ) { it.remove(); } }
// faster iteration by avoiding hasNext(): TObjectByteIterator iterator = map.iterator(); for ( int i = map.size(); i-- > 0; ) { iterator.advance(); doSomethingWithKeyAndValue( iterator.key(), iterator.value() ); }
Modifier and Type | Method | Description |
---|---|---|
K |
key() |
Provides access to the key of the mapping at the iterator's position.
|
byte |
setValue(byte val) |
Replace the value of the mapping at the iterator's position with the
specified value.
|
byte |
value() |
Provides access to the value of the mapping at the iterator's position.
|
advance
K key()
byte value()
byte setValue(byte val)
val
- the value to set in the current entry