Set of points. More...
#include <SgPointSet.h>
Classes | |
class | PrecompAllPoints |
Precomputed point sets with all points depending on board size. More... | |
Public Member Functions | |
SgPointSet () | |
~SgPointSet () | |
SgPointSet (const SgVector< SgPoint > &vector) | |
SgPointSet & | operator-= (const SgPointSet &other) |
SgPointSet & | operator&= (const SgPointSet &other) |
SgPointSet & | operator|= (const SgPointSet &other) |
SgPointSet & | operator^= (const SgPointSet &other) |
bool | operator== (const SgPointSet &other) const |
bool | operator!= (const SgPointSet &other) const |
bool | operator[] (SgPoint p) const |
Return whether point 'p' is set. | |
bool | Disjoint (const SgPointSet &s) const |
bool | Adjacent (const SgPointSet &s) const |
Test if this contains a Point adjacent to a Point in s. | |
bool | Adjacent8To (SgPoint p) const |
bool | AdjacentOnlyTo (const SgPointSet &s, int boardSize) const |
Test if all points adjacent to this are contained in s. | |
bool | AdjacentTo (SgPoint p) const |
bool | AllAdjacentTo (const SgPointSet &s) const |
Test if all Points in this are adjacent to some Point in s. | |
int | Size () const |
bool | IsSize (int size) const |
bool | MinSetSize (int size) const |
bool | MaxSetSize (int size) const |
bool | IsEmpty () const |
bool | NonEmpty () const |
SgPointSet | Border (int boardSize) const |
4-Neighbor points of set | |
SgPointSet | Border8 (int boardSize) const |
8-Neighbor points of set | |
SgPointSet | BorderNoClip () const |
Compute border without clipping to board size. | |
SgPoint | Center () const |
SgPoint as close to the center of set as possible. | |
bool | CheckedContains (SgPoint p, bool doRangeCheck=true, bool onBoardCheck=false) const |
Return whether point 'p' is set. | |
SgPointSet & | Clear () |
SgPointSet | Component (SgPoint p) const |
Compute connected component by iterative Border calculation. | |
SgPointSet | Component8 (SgPoint p) const |
Good for small diameter sets. | |
SgPointSet | ConnComp (SgPoint p) const |
Good for large diameter sets. | |
SgPointSet | ConnComp8 (SgPoint p) const |
8-neighbors | |
bool | Contains (SgPoint p) const |
Check if contains point. | |
bool | ContainsPoint (SgPoint p) const |
Check if contains point. | |
SgRect | EnclosingRect () const |
SgPointSet & | Exclude (SgPoint p) |
SgPointSet & | Exclude (const SgVector< SgPoint > &vector) |
void | Grow (int boardSize) |
Include 4-neighbor points in set. | |
void | Grow (SgPointSet *newArea, int boardSize) |
Returns newly added points. | |
void | Grow8 (int boardSize) |
Include 8-neighbor points in set. | |
SgPointSet & | Include (SgPoint p) |
bool | IsConnected () const |
Whether set is connected or not. | |
bool | Is8Connected () const |
Whether set is connected or not. | |
SgPointSet | Kernel (int boardSize) const |
Points of set surrounded by set. | |
bool | MaxOverlap (const SgPointSet &other, int max) const |
At most 'max' common points. | |
bool | MinOverlap (const SgPointSet &s, int min) const |
At least 'min' common points. | |
bool | NewMark (SgPoint p) |
bool | Overlaps (const SgPointSet &other) const |
SgPoint | PointOf () const |
First point of set. | |
bool | SubsetOf (const SgPointSet &other) const |
Is this set a subset of s? | |
bool | SupersetOf (const SgPointSet &other) const |
Is this set a superset of s? | |
void | Swap (SgPointSet &other) throw () |
SgPointSet & | Toggle (SgPoint p) |
void | ToVector (SgVector< SgPoint > *vector) const |
void | Write (std::ostream &out, int boardSize) const |
bool | IsCloseTo (SgPoint p) const |
Return whether point 'p' is close to a point in set. | |
Static Public Member Functions | |
static const SgPointSet & | AllPoints (int boardSize) |
Private Member Functions | |
SgPointSet | operator>> (int n) const |
SgPointSet | operator<< (int n) const |
Private Attributes | |
std::bitset< SG_MAXPOINT > | m_a |
Static Private Attributes | |
static PrecompAllPoints | s_allPoints |
Friends | |
class | SgSetIterator |
Related Functions | |
(Note that these are not member functions.) | |
SgPointSet | operator- (const SgPointSet &L, const SgPointSet &R) |
Compute difference between point sets. | |
SgPointSet | operator& (const SgPointSet &L, const SgPointSet &R) |
Compute intersection between point sets. | |
SgPointSet | operator| (const SgPointSet &L, const SgPointSet &R) |
Compute union between point sets. | |
SgPointSet | operator^ (const SgPointSet &L, const SgPointSet &R) |
Compute XOR between point sets. | |
std::ostream & | operator<< (std::ostream &out, const SgPointSet &set) |
Set of points.
Represents a set of points on the Go board. This class is efficient for bit-level operations on the board as a whole.
Definition at line 24 of file SgPointSet.h.
SgPointSet::SgPointSet | ( | ) |
Definition at line 236 of file SgPointSet.h.
Referenced by SgPointSet::PrecompAllPoints::PrecompAllPoints().
SgPointSet::~SgPointSet | ( | ) |
Definition at line 240 of file SgPointSet.h.
Definition at line 131 of file SgPointSet.cpp.
bool SgPointSet::Adjacent | ( | const SgPointSet & | s | ) | const |
Test if this contains a Point adjacent to a Point in s.
Definition at line 221 of file SgPointSet.cpp.
References BorderNoClip(), and Overlaps().
bool SgPointSet::Adjacent8To | ( | SgPoint | p | ) | const |
Definition at line 319 of file SgPointSet.h.
References Contains(), SG_ASSERT_BOARDRANGE, SG_NS, and SG_WE.
bool SgPointSet::AdjacentOnlyTo | ( | const SgPointSet & | s, | |
int | boardSize | |||
) | const |
Test if all points adjacent to this are contained in s.
Definition at line 231 of file SgPointSet.cpp.
References Border(), and SubsetOf().
bool SgPointSet::AdjacentTo | ( | SgPoint | p | ) | const |
Definition at line 310 of file SgPointSet.h.
References Contains(), SG_ASSERT_BOARDRANGE, SG_NS, and SG_WE.
bool SgPointSet::AllAdjacentTo | ( | const SgPointSet & | s | ) | const |
Test if all Points in this are adjacent to some Point in s.
Definition at line 226 of file SgPointSet.cpp.
References BorderNoClip(), and SubsetOf().
const SgPointSet & SgPointSet::AllPoints | ( | int | boardSize | ) | [static] |
Definition at line 283 of file SgPointSet.h.
References SgPointSet::PrecompAllPoints::Get(), and s_allPoints.
Referenced by Border(), Border8(), Grow(), Grow8(), and Kernel().
SgPointSet SgPointSet::Border | ( | int | boardSize | ) | const |
4-Neighbor points of set
Definition at line 43 of file SgPointSet.cpp.
References AllPoints(), and BorderNoClip().
Referenced by AdjacentOnlyTo().
SgPointSet SgPointSet::Border8 | ( | int | boardSize | ) | const |
8-Neighbor points of set
Definition at line 190 of file SgPointSet.cpp.
References AllPoints(), SG_NS, and SG_WE.
SgPointSet SgPointSet::BorderNoClip | ( | ) | const |
Compute border without clipping to board size.
Definition at line 48 of file SgPointSet.cpp.
Referenced by Adjacent(), AllAdjacentTo(), Border(), and Component().
SgPoint SgPointSet::Center | ( | ) | const |
SgPoint as close to the center of set as possible.
Definition at line 273 of file SgPointSet.cpp.
References SgRect::Center(), Contains(), SgPointUtil::Distance(), EnclosingRect(), SgRect::IsEmpty(), SG_MAX_SIZE, and SG_NULLPOINT.
Referenced by operator<<().
bool SgPointSet::CheckedContains | ( | SgPoint | p, | |
bool | doRangeCheck = true , |
|||
bool | onBoardCheck = false | |||
) | const |
Return whether point 'p' is set.
Definition at line 385 of file SgPointSet.h.
References m_a, SgPointUtil::Pt(), SG_ASSERT_BOARDRANGE, SG_ASSERTRANGE, and SG_MAX_SIZE.
Referenced by ContainsPoint().
SgPointSet & SgPointSet::Clear | ( | ) |
Definition at line 367 of file SgPointSet.h.
References m_a.
Referenced by SgSimpleSet::GetPoints(), SgMarker::GetPoints(), and SgPointSet().
SgPointSet SgPointSet::Component | ( | SgPoint | p | ) | const |
Compute connected component by iterative Border calculation.
Definition at line 58 of file SgPointSet.cpp.
References BorderNoClip(), and Include().
Referenced by IsConnected().
SgPointSet SgPointSet::Component8 | ( | SgPoint | p | ) | const |
Good for small diameter sets.
SgPointSet SgPointSet::ConnComp | ( | SgPoint | p | ) | const |
Good for large diameter sets.
Definition at line 71 of file SgPointSet.cpp.
References Contains(), Exclude(), Include(), and SG_MAXPOINT.
Referenced by SgConnCompIterator::operator++().
SgPointSet SgPointSet::ConnComp8 | ( | SgPoint | p | ) | const |
8-neighbors
Definition at line 97 of file SgPointSet.cpp.
References Contains(), Exclude(), Include(), SG_ASSERT, SG_MAXPOINT, and SupersetOf().
Referenced by Is8Connected(), and SgConnComp8Iterator::operator++().
bool SgPointSet::Contains | ( | SgPoint | p | ) | const |
Check if contains point.
Can be called with out-of-board points, otherwise use ContainsPoints().
Definition at line 380 of file SgPointSet.h.
References m_a.
Referenced by SgMiaiStrategy::AddPair(), Adjacent8To(), AdjacentTo(), Center(), ConnComp(), ConnComp8(), IsCloseTo(), NewMark(), operator[](), and Write().
bool SgPointSet::ContainsPoint | ( | SgPoint | p | ) | const |
Check if contains point.
Can only be called with on-board points, otherwise use Contains().
Definition at line 400 of file SgPointSet.h.
References CheckedContains().
bool SgPointSet::Disjoint | ( | const SgPointSet & | s | ) | const |
Definition at line 305 of file SgPointSet.h.
References Overlaps().
SgRect SgPointSet::EnclosingRect | ( | ) | const |
Definition at line 300 of file SgPointSet.cpp.
References SgRect::Include().
Referenced by Center().
SgPointSet & SgPointSet::Exclude | ( | SgPoint | p | ) |
Definition at line 353 of file SgPointSet.h.
References m_a, and SG_ASSERT_BOARDRANGE.
Referenced by SgBoardConst::BoardConstImpl::BoardConstImpl(), ConnComp(), ConnComp8(), SgEvaluatedMoves::Disable(), Exclude(), SgIncrementalStack::SubtractAndAddPoints(), and SgIncrementalStack::SubtractPoints().
SgPointSet & SgPointSet::Exclude | ( | const SgVector< SgPoint > & | vector | ) |
Definition at line 124 of file SgPointSet.cpp.
References Exclude().
void SgPointSet::Grow | ( | int | boardSize | ) |
Include 4-neighbor points in set.
Definition at line 155 of file SgPointSet.cpp.
References AllPoints(), SG_NS, and SG_WE.
void SgPointSet::Grow | ( | SgPointSet * | newArea, | |
int | boardSize | |||
) |
Returns newly added points.
Definition at line 165 of file SgPointSet.cpp.
References AllPoints(), SG_NS, and SG_WE.
void SgPointSet::Grow8 | ( | int | boardSize | ) |
Include 8-neighbor points in set.
Definition at line 176 of file SgPointSet.cpp.
References AllPoints(), SG_NS, and SG_WE.
SgPointSet & SgPointSet::Include | ( | SgPoint | p | ) |
Definition at line 360 of file SgPointSet.h.
References m_a, and SG_ASSERT_BOARDRANGE.
Referenced by SgIncrementalStack::AddPoints(), SgBoardConst::BoardConstImpl::BoardConstImpl(), Component(), ConnComp(), ConnComp8(), SgMiaiStrategy::Dependency(), SgEvaluatedMoves::Enable(), SgSimpleSet::GetPoints(), SgMarker::GetPoints(), SgMiaiStrategy::HasOverlappingMiaiPairs(), NewMark(), SgPointSet::PrecompAllPoints::PrecompAllPoints(), SgReadPointSet::Read(), SgPointSetUtil::Rotate(), SgPointSet(), and SgIncrementalStack::SubtractAndAddPoints().
bool SgPointSet::Is8Connected | ( | ) | const |
Whether set is connected or not.
Definition at line 317 of file SgPointSet.cpp.
References ConnComp8(), PointOf(), and SG_NULLPOINT.
bool SgPointSet::IsCloseTo | ( | SgPoint | p | ) | const |
Return whether point 'p' is close to a point in set.
in implementation: const int MAX_CLOSE_DISTANCE = 3;
Definition at line 236 of file SgPointSet.cpp.
References Contains().
bool SgPointSet::IsConnected | ( | ) | const |
Whether set is connected or not.
Definition at line 308 of file SgPointSet.cpp.
References Component(), PointOf(), and SG_NULLPOINT.
bool SgPointSet::IsEmpty | ( | ) | const |
Definition at line 343 of file SgPointSet.h.
References m_a.
Referenced by NonEmpty(), and operator<<().
bool SgPointSet::IsSize | ( | int | size | ) | const |
Definition at line 205 of file SgPointSet.cpp.
SgPointSet SgPointSet::Kernel | ( | int | boardSize | ) | const |
Points of set surrounded by set.
Definition at line 250 of file SgPointSet.cpp.
References AllPoints(), SG_NS, and SG_WE.
bool SgPointSet::MaxOverlap | ( | const SgPointSet & | other, | |
int | max | |||
) | const |
At most 'max' common points.
Definition at line 293 of file SgPointSet.h.
References Size().
Referenced by MinOverlap().
bool SgPointSet::MaxSetSize | ( | int | size | ) | const |
Definition at line 216 of file SgPointSet.cpp.
References Size().
bool SgPointSet::MinOverlap | ( | const SgPointSet & | s, | |
int | min | |||
) | const |
bool SgPointSet::MinSetSize | ( | int | size | ) | const |
Definition at line 211 of file SgPointSet.cpp.
References Size().
bool SgPointSet::NewMark | ( | SgPoint | p | ) |
Definition at line 410 of file SgPointSet.h.
References Contains(), and Include().
bool SgPointSet::NonEmpty | ( | ) | const |
Definition at line 348 of file SgPointSet.h.
References IsEmpty().
bool SgPointSet::operator!= | ( | const SgPointSet & | other | ) | const |
Definition at line 278 of file SgPointSet.h.
References m_a.
SgPointSet & SgPointSet::operator&= | ( | const SgPointSet & | other | ) |
Definition at line 255 of file SgPointSet.h.
References m_a.
SgPointSet & SgPointSet::operator-= | ( | const SgPointSet & | other | ) |
Definition at line 249 of file SgPointSet.h.
References m_a.
SgPointSet SgPointSet::operator<< | ( | int | n | ) | const [private] |
Definition at line 428 of file SgPointSet.h.
References m_a.
bool SgPointSet::operator== | ( | const SgPointSet & | other | ) | const |
Definition at line 273 of file SgPointSet.h.
References m_a.
SgPointSet SgPointSet::operator>> | ( | int | n | ) | const [private] |
Definition at line 421 of file SgPointSet.h.
References m_a.
bool SgPointSet::operator[] | ( | SgPoint | p | ) | const |
Return whether point 'p' is set.
Definition at line 405 of file SgPointSet.h.
References Contains().
SgPointSet & SgPointSet::operator^= | ( | const SgPointSet & | other | ) |
Definition at line 267 of file SgPointSet.h.
References m_a.
SgPointSet & SgPointSet::operator|= | ( | const SgPointSet & | other | ) |
Definition at line 261 of file SgPointSet.h.
References m_a.
bool SgPointSet::Overlaps | ( | const SgPointSet & | other | ) | const |
Definition at line 288 of file SgPointSet.h.
References m_a.
Referenced by Adjacent(), and Disjoint().
SgPoint SgPointSet::PointOf | ( | ) | const |
First point of set.
Definition at line 263 of file SgPointSet.cpp.
References SG_NULLPOINT.
Referenced by Is8Connected(), and IsConnected().
int SgPointSet::Size | ( | ) | const |
Definition at line 338 of file SgPointSet.h.
References m_a.
Referenced by IsSize(), MaxOverlap(), MaxSetSize(), MinSetSize(), operator<<(), and SgWritePointSet::Write().
bool SgPointSet::SubsetOf | ( | const SgPointSet & | other | ) | const |
Is this set a subset of s?
Definition at line 328 of file SgPointSet.h.
References m_a.
Referenced by AdjacentOnlyTo(), and AllAdjacentTo().
bool SgPointSet::SupersetOf | ( | const SgPointSet & | other | ) | const |
Is this set a superset of s?
Definition at line 333 of file SgPointSet.h.
References m_a.
Referenced by ConnComp8().
void SgPointSet::Swap | ( | SgPointSet & | other | ) | throw () |
Definition at line 244 of file SgPointSet.h.
SgPointSet & SgPointSet::Toggle | ( | SgPoint | p | ) |
Definition at line 373 of file SgPointSet.h.
Definition at line 138 of file SgPointSet.cpp.
References SgVector< T >::Clear(), and SgVector< T >::PushBack().
Referenced by SgNode::SetListProp().
void SgPointSet::Write | ( | std::ostream & | out, | |
int | boardSize | |||
) | const |
Definition at line 145 of file SgPointSet.cpp.
References Contains(), and SgPointUtil::Pt().
SgPointSet operator& | ( | const SgPointSet & | L, | |
const SgPointSet & | R | |||
) | [related] |
Compute intersection between point sets.
Definition at line 217 of file SgPointSet.h.
SgPointSet operator- | ( | const SgPointSet & | L, | |
const SgPointSet & | R | |||
) | [related] |
Compute difference between point sets.
Definition at line 210 of file SgPointSet.h.
std::ostream & operator<< | ( | std::ostream & | out, | |
const SgPointSet & | set | |||
) | [related] |
Definition at line 59 of file SgPointSetUtil.cpp.
SgPointSet operator^ | ( | const SgPointSet & | L, | |
const SgPointSet & | R | |||
) | [related] |
Compute XOR between point sets.
Definition at line 231 of file SgPointSet.h.
SgPointSet operator| | ( | const SgPointSet & | L, | |
const SgPointSet & | R | |||
) | [related] |
Compute union between point sets.
Definition at line 224 of file SgPointSet.h.
friend class SgSetIterator [friend] |
Definition at line 195 of file SgPointSet.h.
std::bitset<SG_MAXPOINT> SgPointSet::m_a [private] |
Definition at line 197 of file SgPointSet.h.
Referenced by CheckedContains(), Clear(), Contains(), Exclude(), SgSetIterator::FindNext(), Include(), IsEmpty(), operator!=(), operator&=(), SgSetIterator::operator*(), operator-=(), operator<<(), operator==(), operator>>(), operator^=(), operator|=(), Overlaps(), SgSetIterator::Size(), Size(), SubsetOf(), SupersetOf(), and Toggle().
SgPointSet::PrecompAllPoints SgPointSet::s_allPoints [static, private] |
Definition at line 199 of file SgPointSet.h.
Referenced by AllPoints().