#include <point-set.h>
All features in the set must have the same dimension, and this is determined when the PointSet is constructed. Points may be added, removed, and replaced by index. When points are inserted, PointSet will automatically check to make sure that the points all have the same dimension.
This is called a PointSet just to maintain name compatibility with previous versions, even though it is actually an array.
Public Member Functions | |
PointSet (int point_dim) | |
Creates an initially empty set (such that size() == 0). | |
~PointSet () | |
PointSet (const PointSet &other) | |
void | CopyFrom (const PointSet &other) |
int | size () const |
int | point_dim () const |
void | set_point_dim (int new_dim) |
Set the point dim. Only works when size() == 0. | |
const Point & | point (int index) const |
Returns a const reference to the point at <index>. | |
Point * | mutable_point (int index) const |
const Point & | operator[] (int index) const |
Point * | add_point (const Point &point) |
Adds a copy of the point to the end of the list. | |
Point * | add_point () |
Adds a new, empty (all zeroes) Point and returns a pointer to it. | |
void | remove_point (int index) |
Removes the point at <index>. | |
void | clear () |
Deletes all of the points. | |
void | WriteToStream (ostream &output_stream) const |
Writes the point set to a stream. | |
void | ReadFromStream (istream &input_stream) |
Reads the point set from a stream. |
~PointSet | ( | ) |
void CopyFrom | ( | const PointSet & | other | ) |
int size | ( | ) | const [inline] |
int point_dim | ( | ) | const [inline] |
void set_point_dim | ( | int | new_dim | ) |
Set the point dim. Only works when size() == 0.
const Point & point | ( | int | index | ) | const |
Returns a const reference to the point at <index>.
Point * mutable_point | ( | int | index | ) | const |
const Point& operator[] | ( | int | index | ) | const [inline] |
Adds a copy of the point to the end of the list.
Returns a pointer to the Point that was just added.
void remove_point | ( | int | index | ) |
Removes the point at <index>.
void clear | ( | ) |
Deletes all of the points.
void WriteToStream | ( | ostream & | output_stream | ) | const |
Writes the point set to a stream.
The format is as follows:
Note that the point dim is not written to the stream.
void ReadFromStream | ( | istream & | input_stream | ) |
Reads the point set from a stream.
This function will clear any Features present currently. It will also assume that the incoming PointSet has the proper feature dim (observe that a serialized PointSet doesn't actually record feature dim-- that is up to PointSetList to remember).