public class PointSet extends Object
(x, y).| Constructor and Description |
|---|
PointSet(int rangeX,
int rangeY)
Creates a point set that can contain points within the given range of values.
|
| Modifier and Type | Method and Description |
|---|---|
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() |
public PointSet(int rangeX,
int rangeY)
rangeX - the maximum x-axis range.rangeY - the maximum y-axis range.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()
Copyright © 2015. All rights reserved.