added turn restrictions
This commit is contained in:
parent
561b60c5cb
commit
e48cbd49cb
18 changed files with 383 additions and 32 deletions
|
|
@ -21,7 +21,7 @@ public class CompactLongMap<V>
|
|||
private int size = 0;
|
||||
private int _maxKeepExponent = 14; // the maximum exponent to keep the invalid arrays
|
||||
|
||||
private V value_in;
|
||||
protected V value_in;
|
||||
protected V value_out;
|
||||
|
||||
protected static final int MAXLISTS = 31; // enough for size Integer.MAX_VALUE
|
||||
|
|
|
|||
|
|
@ -33,9 +33,22 @@ public class FrozenLongMap<V> extends CompactLongMap<V>
|
|||
@Override
|
||||
public boolean put( long id, V value )
|
||||
{
|
||||
throw new RuntimeException( "cannot put on FrozenLongIntMap" );
|
||||
try
|
||||
{
|
||||
value_in = value;
|
||||
if ( contains( id, true ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
throw new RuntimeException( "cannot only put on existing key in FrozenLongIntMap" );
|
||||
}
|
||||
finally
|
||||
{
|
||||
value_in = null;
|
||||
value_out = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void fastPut( long id, V value )
|
||||
{
|
||||
|
|
@ -79,14 +92,17 @@ public class FrozenLongMap<V> extends CompactLongMap<V>
|
|||
if ( a[n] == id )
|
||||
{
|
||||
value_out = flv.get(n);
|
||||
if ( doPut )
|
||||
{
|
||||
flv.set( n, value_in );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the value for "id",
|
||||
* Throw an exception if not contained in the map.
|
||||
* @return the value for "id", or null if key unknown
|
||||
*/
|
||||
@Override
|
||||
public V get( long id )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue