com.threerings.tudey.util
Class CoordIntMap

java.lang.Object
  extended by java.util.AbstractMap<Coord,Integer>
      extended by com.threerings.tudey.util.CoordIntMap
All Implemented Interfaces:
Exportable, Map<Coord,Integer>

public class CoordIntMap
extends AbstractMap<Coord,Integer>
implements Exportable

Maps pairs of integer coordinates to integer values.


Nested Class Summary
static class CoordIntMap.CoordIntEntry
          An entry in the map.
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
CoordIntMap()
          Creates a new coord int map with a top-level cell size of 8x8 and with the value -1 representing the absence of an entry.
CoordIntMap(int granularity)
          Creates a new coord int map with the value -1 representing the absence of an entry.
CoordIntMap(int granularity, int empty)
          Creates a new coord int map.
 
Method Summary
 void clear()
           
 boolean containsKey(int x, int y)
          Determines whether this map contains an entry for the specified coordinates.
 boolean containsKey(Object key)
           
 boolean containsValue(int value)
          Determines whether this map contains the specified value.
 boolean containsValue(Object value)
           
 Set<CoordIntMap.CoordIntEntry> coordIntEntrySet()
          Returns a set view of the map entries.
 Set<Map.Entry<Coord,Integer>> entrySet()
           
 int get(int x, int y)
          Retrieves the value at the specified coordinates.
 Integer get(Object key)
           
 boolean isEmpty()
           
 Integer put(Coord key, Integer value)
           
 int put(int x, int y, int value)
          Sets the value at the specified coordinates.
 void readFields(Importer in)
          Custom field read method.
 int remove(int x, int y)
          Removes the value at the specified coordinates.
 Integer remove(Object key)
           
 int setBits(int x, int y, int bits)
          Stores the bitwise OR of the previous value and the specified bits at the specified coordinates.
 int size()
           
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, keySet, putAll, toString, values
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CoordIntMap

public CoordIntMap()
Creates a new coord int map with a top-level cell size of 8x8 and with the value -1 representing the absence of an entry.


CoordIntMap

public CoordIntMap(int granularity)
Creates a new coord int map with the value -1 representing the absence of an entry.

Parameters:
granularity - the size of the top-level cells, expressed as a power of two (e.g., 3 for cell size 8).

CoordIntMap

public CoordIntMap(int granularity,
                   int empty)
Creates a new coord int map.

Parameters:
granularity - the size of the top-level cells, expressed as a power of two (e.g., 3 for a cell size of 8 by 8).
empty - the value indicating the absence of an entry.
Method Detail

get

public int get(int x,
               int y)
Retrieves the value at the specified coordinates.


put

public int put(int x,
               int y,
               int value)
Sets the value at the specified coordinates.

Returns:
the previously stored value.

setBits

public int setBits(int x,
                   int y,
                   int bits)
Stores the bitwise OR of the previous value and the specified bits at the specified coordinates.

Returns:
the previously stored value.

remove

public int remove(int x,
                  int y)
Removes the value at the specified coordinates.

Returns:
the previously stored value.

containsKey

public boolean containsKey(int x,
                           int y)
Determines whether this map contains an entry for the specified coordinates.


containsValue

public boolean containsValue(int value)
Determines whether this map contains the specified value.


readFields

public void readFields(Importer in)
                throws IOException
Custom field read method.

Throws:
IOException

coordIntEntrySet

public Set<CoordIntMap.CoordIntEntry> coordIntEntrySet()
Returns a set view of the map entries.


entrySet

public Set<Map.Entry<Coord,Integer>> entrySet()
Specified by:
entrySet in interface Map<Coord,Integer>
Specified by:
entrySet in class AbstractMap<Coord,Integer>

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map<Coord,Integer>
Overrides:
containsKey in class AbstractMap<Coord,Integer>

containsValue

public boolean containsValue(Object value)
Specified by:
containsValue in interface Map<Coord,Integer>
Overrides:
containsValue in class AbstractMap<Coord,Integer>

get

public Integer get(Object key)
Specified by:
get in interface Map<Coord,Integer>
Overrides:
get in class AbstractMap<Coord,Integer>

put

public Integer put(Coord key,
                   Integer value)
Specified by:
put in interface Map<Coord,Integer>
Overrides:
put in class AbstractMap<Coord,Integer>

remove

public Integer remove(Object key)
Specified by:
remove in interface Map<Coord,Integer>
Overrides:
remove in class AbstractMap<Coord,Integer>

clear

public void clear()
Specified by:
clear in interface Map<Coord,Integer>
Overrides:
clear in class AbstractMap<Coord,Integer>

size

public int size()
Specified by:
size in interface Map<Coord,Integer>
Overrides:
size in class AbstractMap<Coord,Integer>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Map<Coord,Integer>
Overrides:
isEmpty in class AbstractMap<Coord,Integer>


Copyright © 2011. All Rights Reserved.