#include <SgPointSet.h>
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 26 of file SgPointSet.h.
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) |
Classes | |
| class | PrecompAllPoints |
| Precomputed point sets with all points depending on board size. More... | |
| SgPointSet::SgPointSet | ( | ) |
Definition at line 248 of file SgPointSet.h.
Referenced by SgPointSet::PrecompAllPoints::PrecompAllPoints().
| SgPointSet::~SgPointSet | ( | ) |
Definition at line 252 of file SgPointSet.h.
| bool SgPointSet::Adjacent | ( | const SgPointSet & | s | ) | const |
Test if this contains a Point adjacent to a Point in s.
Definition at line 222 of file SgPointSet.cpp.
References BorderNoClip(), and Overlaps().
| bool SgPointSet::Adjacent8To | ( | SgPoint | p | ) | const |
Definition at line 331 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 232 of file SgPointSet.cpp.
References Border(), and SubsetOf().
| bool SgPointSet::AdjacentTo | ( | SgPoint | p | ) | const |
Definition at line 322 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 227 of file SgPointSet.cpp.
References BorderNoClip(), and SubsetOf().
| const SgPointSet & SgPointSet::AllPoints | ( | int | boardSize | ) | [static] |
Definition at line 295 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 44 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 191 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 49 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 274 of file SgPointSet.cpp.
References SgRect::Center(), Contains(), SgPointUtil::Distance(), EnclosingRect(), SgRect::IsEmpty(), MaxDistance(), 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 397 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 379 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 59 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 72 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 98 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 392 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 412 of file SgPointSet.h.
References CheckedContains().
| bool SgPointSet::Disjoint | ( | const SgPointSet & | s | ) | const |
| SgRect SgPointSet::EnclosingRect | ( | ) | const |
Definition at line 301 of file SgPointSet.cpp.
References SgRect::Include().
Referenced by Center().
| SgPointSet & SgPointSet::Exclude | ( | const SgVector< SgPoint > & | vector | ) |
| SgPointSet & SgPointSet::Exclude | ( | SgPoint | p | ) |
Definition at line 365 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().
| void SgPointSet::Grow | ( | SgPointSet * | newArea, | |
| int | boardSize | |||
| ) |
Returns newly added points.
Definition at line 166 of file SgPointSet.cpp.
References AllPoints(), SG_NS, and SG_WE.
| void SgPointSet::Grow | ( | int | boardSize | ) |
Include 4-neighbor points in set.
Definition at line 156 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 177 of file SgPointSet.cpp.
References AllPoints(), SG_NS, and SG_WE.
| SgPointSet & SgPointSet::Include | ( | SgPoint | p | ) |
Definition at line 372 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 318 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 237 of file SgPointSet.cpp.
References Contains(), and MaxDistance().
| bool SgPointSet::IsConnected | ( | ) | const |
Whether set is connected or not.
Definition at line 309 of file SgPointSet.cpp.
References Component(), PointOf(), and SG_NULLPOINT.
| bool SgPointSet::IsEmpty | ( | ) | const |
Definition at line 355 of file SgPointSet.h.
References m_a.
Referenced by NonEmpty(), and operator<<().
| bool SgPointSet::IsSize | ( | int | size | ) | const |
| SgPointSet SgPointSet::Kernel | ( | int | boardSize | ) | const |
Points of set surrounded by set.
Definition at line 251 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 305 of file SgPointSet.h.
References Size().
Referenced by MinOverlap().
| bool SgPointSet::MaxSetSize | ( | int | size | ) | const |
| bool SgPointSet::MinOverlap | ( | const SgPointSet & | s, | |
| int | min | |||
| ) | const |
| bool SgPointSet::MinSetSize | ( | int | size | ) | const |
| bool SgPointSet::NewMark | ( | SgPoint | p | ) |
| bool SgPointSet::NonEmpty | ( | ) | const |
| SgPointSet & SgPointSet::operator &= | ( | const SgPointSet & | other | ) |
| bool SgPointSet::operator!= | ( | const SgPointSet & | other | ) | const |
| SgPointSet & SgPointSet::operator-= | ( | const SgPointSet & | other | ) |
| SgPointSet SgPointSet::operator<< | ( | int | n | ) | const [private] |
| bool SgPointSet::operator== | ( | const SgPointSet & | other | ) | const |
| SgPointSet SgPointSet::operator>> | ( | int | n | ) | const [private] |
| bool SgPointSet::operator[] | ( | SgPoint | p | ) | const |
Return whether point 'p' is set.
Definition at line 417 of file SgPointSet.h.
References Contains().
| SgPointSet & SgPointSet::operator^= | ( | const SgPointSet & | other | ) |
| SgPointSet & SgPointSet::operator|= | ( | const SgPointSet & | other | ) |
| bool SgPointSet::Overlaps | ( | const SgPointSet & | other | ) | const |
Definition at line 300 of file SgPointSet.h.
References m_a.
Referenced by Adjacent(), and Disjoint().
| SgPoint SgPointSet::PointOf | ( | ) | const |
First point of set.
Definition at line 264 of file SgPointSet.cpp.
References SG_NULLPOINT.
Referenced by Is8Connected(), and IsConnected().
| int SgPointSet::Size | ( | ) | const |
Definition at line 350 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 340 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 345 of file SgPointSet.h.
References m_a.
Referenced by ConnComp8().
| void SgPointSet::Swap | ( | SgPointSet & | other | ) | throw () |
Definition at line 256 of file SgPointSet.h.
| SgPointSet & SgPointSet::Toggle | ( | SgPoint | p | ) |
Definition at line 139 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 |
| SgPointSet operator & | ( | const SgPointSet & | L, | |
| const SgPointSet & | R | |||
| ) | [related] |
| SgPointSet operator- | ( | const SgPointSet & | L, | |
| const SgPointSet & | R | |||
| ) | [related] |
| std::ostream & operator<< | ( | std::ostream & | out, | |
| const SgPointSet & | set | |||
| ) | [related] |
Definition at line 60 of file SgPointSetUtil.cpp.
| SgPointSet operator^ | ( | const SgPointSet & | L, | |
| const SgPointSet & | R | |||
| ) | [related] |
| SgPointSet operator| | ( | const SgPointSet & | L, | |
| const SgPointSet & | R | |||
| ) | [related] |
friend class SgSetIterator [friend] |
Definition at line 203 of file SgPointSet.h.
std::bitset<SG_MAXPOINT> SgPointSet::m_a [private] |
Definition at line 205 of file SgPointSet.h.
Referenced by CheckedContains(), Clear(), Contains(), Exclude(), SgSetIterator::FindNext(), Include(), IsEmpty(), operator &=(), SgSetIterator::operator *(), operator!=(), operator-=(), operator<<(), operator==(), operator>>(), operator^=(), operator|=(), Overlaps(), SgSetIterator::Size(), Size(), SubsetOf(), SupersetOf(), and Toggle().
SgPointSet::PrecompAllPoints SgPointSet::s_allPoints [static, private] |