TLongList list = new TLongArrayList( vals );
TLongCollection set = map.valueCollection();
assertEquals( map.getNoEntryValue(), set.getNoEntryValue() );
// test basic iterator function.
TLongIterator iter = set.iterator();
while ( iter.hasNext() ) {
long val = iter.next();
assertTrue( "value collection should only contain values: " + val + ", set; " + set,
list.contains( val ) );
}
assertFalse( iter.hasNext() );
try {
iter.next();
fail( "Expect NoSuchElementException" );
}
catch ( NoSuchElementException ex ) {
// Expected.
}
// Start over with new iterator -- test iter.remove()
iter = set.iterator();
while ( iter.hasNext() ) {
long val = iter.next();
assertTrue( "value collection should only contain values: " + val + ", set; " + set,
list.contains( val ) );
if ( val == vals[3] ) {
iter.remove();
assertFalse( "set contains removed element: " + val + ", set: " + set,
set.contains( val ) );
}
}
assertEquals( map.size(), set.size() );