|
Genuts API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.genuts.gameui.util.SpriteChecker
This class implements a sprites checker to store an uniq instance of sprites.
An instance of SpriteChecker has two parameters that
affect its efficiency: its capacity and its load
factor. The load factor should be between 0.0 and 1.0. When
the number of entries in the sprites checker exceeds the product of the
load factor and the current capacity, the capacity is increased by
calling the rehash method. Larger load factors use
memory more efficiently, at the expense of larger expected time
per lookup.
If many entries are to be made into a SpriteChecker,
creating it with a sufficiently large capacity may allow the
entries to be inserted more efficiently than letting it perform
automatic rehashing as needed to grow the table.
| Nested Class Summary | |
class |
SpriteChecker.HashSimpleVector
Vector specialy designed for HashEntry. |
(package private) class |
SpriteChecker.HashtableEntry
Sprites Checker collision list. |
(package private) class |
SpriteChecker.SpriteCheckerEnumerator
A sprites checker enumerator class. |
| Field Summary | |
protected int |
count
The total number of entries in the sprites checker. |
protected SpriteChecker.HashSimpleVector |
freeEntries
Unused HashEntry |
protected float |
loadFactor
The load factor for the sprites checker. |
protected SpriteChecker.HashtableEntry[] |
table
The sprites checker data. |
protected int |
threshold
Rehashes the table when count exceeds this threshold. |
| Constructor Summary | |
SpriteChecker()
Constructs a new, empty sprites checker with a default capacity and load factor. |
|
SpriteChecker(int initialCapacity)
Constructs a new, empty sprites checker with the specified initial capacity and default load factor. |
|
SpriteChecker(int initialCapacity,
float loadFactor)
Constructs a new, empty sprites checker with the specified initial capacity and the specified load factor. |
|
| Method Summary | |
void |
clear()
Clears this sprites checker so that it contains no sprites. |
boolean |
contains(Sprite sprite)
Tests if the specified sprite is contained in this sprites checker. |
boolean |
isEmpty()
Tests if this sprites checker is empty. |
static void |
main(java.lang.String[] args)
|
protected void |
rehash()
Rehashes the contents of the sprites checker into a checker with a larger capacity. |
boolean |
remove(Sprite sprite)
Removes the sprite from this sprites checker. |
int |
size()
Returns the number of sprites in this sprites checker. |
java.util.Enumeration |
sprites()
Returns an enumeration of contains sprites in this sprites checker. |
boolean |
store(Sprite sprite)
Stores the specified sprite in this sprites checker. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected SpriteChecker.HashtableEntry[] table
protected SpriteChecker.HashSimpleVector freeEntries
protected int count
protected int threshold
protected float loadFactor
| Constructor Detail |
public SpriteChecker(int initialCapacity,
float loadFactor)
initialCapacity - the initial capacity of the sprites checker.loadFactor - a number between 0.0 and 1.0.
java.lang.IllegalArgumentException - if the initial capacity is less
than or equal to zero, or if the load factor is less than or equal
to zero.public SpriteChecker(int initialCapacity)
initialCapacity - the initial capacity of the sprites checker.public SpriteChecker()
| Method Detail |
public int size()
public boolean isEmpty()
true if this sprites checker contains no sprites,
false otherwise.public java.util.Enumeration sprites()
Enumerationpublic boolean contains(Sprite sprite)
sprite - Sprite to check.
true if the specified sprite is contained in this
sprites checker, false otherwise.protected void rehash()
public boolean store(Sprite sprite)
null.
sprite - the sprite to store.
true if the sprite was already stored in this sprite checker,
false otherwise.
java.lang.NullPointerException - if the sprite is null.public boolean remove(Sprite sprite)
sprite - the sprite that needs to be removed.
true if the sprite was removed from this sprite checker,
false otherwise.public void clear()
public static void main(java.lang.String[] args)
|
Genuts API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||