|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.puzzle.util.PointSet
public class PointSet
The point set class provides an efficient implementation of a set containing two-dimensional
point values as (x, y).
| Nested Class Summary | |
|---|---|
protected class |
PointSet.PointIterator
|
| Field Summary | |
|---|---|
protected int |
_count
The number of points in the set. |
protected boolean[][] |
_points
The points in the set. |
protected int |
_rangeX
The dimensions of the point array. |
protected int |
_rangeY
The dimensions of the point array. |
| Constructor Summary | |
|---|---|
PointSet(int rangeX,
int rangeY)
Creates a point set that can contain points within the given range of values. |
|
| Method Summary | |
|---|---|
boolean |
add(int x,
int y)
Adds a point to the set and returns whether the point was already present in the set. |
void |
addAll(PointSet set)
Adds all points in the given set to this set. |
void |
clear()
Clears all points from this set. |
boolean |
contains(int x,
int y)
Returns whether this set contains the given point. |
boolean |
isEmpty()
Returns whether this set is empty. |
Iterator<Point> |
iterator()
Returns an iterator that iterates over the points in this set, returning them as Point objects. |
boolean |
remove(int x,
int y)
Removes the given point from the set and returns whether the point was present in the set. |
int |
size()
Returns the number of points in the set. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected int _rangeX
protected int _rangeY
protected boolean[][] _points
protected int _count
| Constructor Detail |
|---|
public PointSet(int rangeX,
int rangeY)
rangeX - the maximum x-axis range.rangeY - the maximum y-axis range.| Method Detail |
|---|
public boolean add(int x,
int y)
x - the point x-coordinate.y - the point y-coordinate.
public void addAll(PointSet set)
set - the set containing points to add.public void clear()
public boolean contains(int x,
int y)
x - the point x-coordinate.y - the point y-coordinate.
public boolean isEmpty()
public Iterator<Point> iterator()
Point objects. Note that the iterator uses a single point object internally, and so
callers should create their own copy of the point if they plan to do something fancy with
it.
public boolean remove(int x,
int y)
x - the point x-coordinate.y - the point y-coordinate.
public int size()
public String toString()
toString in class Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||