Regina 7.3 Calculation Engine
|
A reference to one of the two strands of a link that pass each other at a crossing. More...
#include <link/link.h>
Public Member Functions | |
StrandRef () | |
Initialises this to a null reference. More... | |
StrandRef (Crossing *crossing, int strand) | |
Initialises this to the given strand of the given crossing. More... | |
StrandRef (const StrandRef &)=default | |
Creates a new copy of the given strand reference. More... | |
Crossing * | crossing () const |
The crossing that this reference points to. More... | |
int | strand () const |
Indicates whether this reference points to the upper or lower strand of the relevant crossing. More... | |
ssize_t | id () const |
An integer that uniquely identifies this strand within the link. More... | |
bool | operator== (const StrandRef &rhs) const |
Tests whether this and the given reference are identical. More... | |
bool | operator!= (const StrandRef &rhs) const |
Tests whether this and the given reference are not identical. More... | |
StrandRef & | operator= (const StrandRef &)=default |
Sets this to be a copy of the given strand reference. More... | |
StrandRef & | operator++ () |
Moves this reference forward along the direction of the link until it reaches the next crossing. More... | |
StrandRef | operator++ (int) |
Moves this reference forward along the direction of the link until it reaches the next crossing. More... | |
StrandRef & | operator-- () |
Moves this reference backward against the direction of the link until it reaches the previous crossing. More... | |
StrandRef | operator-- (int) |
Moves this reference backward against the direction of the link until it reaches the previous crossing. More... | |
StrandRef | next () const |
Returns the crossing reference that comes immediately after this when walking forward along the direction of the link. More... | |
StrandRef | prev () const |
Returns the crossing reference that comes immediately before this when walking backward against the direction of the link. More... | |
void | jump () |
Jumps to the other strand at the same crossing. More... | |
operator bool () const | |
Tests whether this is a non-null reference. More... | |
Friends | |
class | Link |
class | ModelLinkGraph |
class | Tangle |
A reference to one of the two strands of a link that pass each other at a crossing.
This class is a simple wrapper that stores (i) a pointer to the relevant crossing; and (ii) an integer to denote whether this refers to the upper strand (which passes over the crossing) or the lower strand (which passes under the crossing).
A "null reference" is one whose crossing is the null pointer.
This class can also be used to refer to an arc of a link; that is, a section of the link that runs from one crossing to the next. When used in this way:
These objects are small enough to pass by value and swap with std::swap(), with no need for any specialised move operations or swap functions.
|
inline |
Initialises this to a null reference.
The pointer returned by crossing() will be null
, and the integer returned by strand() will be 0.
|
inline |
Initialises this to the given strand of the given crossing.
The given crossing may be null
, in which case this will become a null reference. If you are creating a null reference, then it is highly recommended that you pass strand as 0, so that comparison tests treat this null reference as equal to a null reference created by the zero-argument constructor.
crossing | the crossing being identified. |
strand | 0 to denote the strand running under the crossing, or 1 to denote the strand running over the crossing. |
|
default |
Creates a new copy of the given strand reference.
|
inline |
The crossing that this reference points to.
The information returned by crossing() and strand() together pinpoint exactly which strand of the link this reference points to.
null
if this is a null reference.
|
inline |
An integer that uniquely identifies this strand within the link.
This integer will be 2c+s, where c is the index of the crossing, and s is 0 or 1 for the lower or upper strand respectively.
If this is a null reference, then id() will return -1.
A strand can be restored from its ID by calling Link::strand().
|
inline |
Jumps to the other strand at the same crossing.
This reference will be changed directly. The crossing will remain the same, but the strand will switch from lower to upper or vice versa.
|
inline |
Returns the crossing reference that comes immediately after this when walking forward along the direction of the link.
Equivalently, this routine returns the reference that would be obtained by calling the increment (++) operator (but, unlike the increment operator, this routine does not actually change the current reference).
null
.
|
inline |
Tests whether this is a non-null reference.
true
if this is not a null reference (i.e., crossing() does not return a null pointer), or false
if this is a null reference.
|
inline |
Tests whether this and the given reference are not identical.
Two references are identical if and only if they return the same values for both crossing() and strand().
null
, 1) then this will not be considered equal to the null reference created by calling StrandRef(), since the latter is equivalent to calling StrandRef(null
, 0).true
if and only if this and rhs are not identical.
|
inline |
Moves this reference forward along the direction of the link until it reaches the next crossing.
(Of course, if the link contains a trivial twist then this may in fact return to the same crossing but the other strand).
This is a preincrement operator: the object will be changed, and then a reference to it will be returned.
null
.
|
inline |
Moves this reference forward along the direction of the link until it reaches the next crossing.
(Of course, if the link contains a trivial twist then this may in fact return to the same crossing but the other strand).
This is a postincrement operator: the object will be changed, but a copy of the original reference will be returned.
null
.
|
inline |
Moves this reference backward against the direction of the link until it reaches the previous crossing.
(Of course, if the link contains a trivial twist then this may in fact return to the same crossing but the other strand).
This is a preincrement operator: the object will be changed, and then a reference to it will be returned.
null
.
|
inline |
Moves this reference backward against the direction of the link until it reaches the previous crossing.
(Of course, if the link contains a trivial twist then this may in fact return to the same crossing but the other strand).
This is a postincrement operator: the object will be changed, but a copy of the original reference will be returned.
null
.Sets this to be a copy of the given strand reference.
|
inline |
Tests whether this and the given reference are identical.
Two references are identical if and only if they return the same values for both crossing() and strand().
null
, 1) then this will not be considered equal to the null reference created by calling StrandRef(), since the latter is equivalent to calling StrandRef(null
, 0).true
if and only if this and rhs are identical.
|
inline |
Returns the crossing reference that comes immediately before this when walking backward against the direction of the link.
Equivalently, this routine returns the reference that would be obtained by calling the decrement (–) operator (but, unlike the decrement operator, this routine does not actually change the current reference).
null
.
|
inline |
Indicates whether this reference points to the upper or lower strand of the relevant crossing.
A value of 1 denotes the upper strand (which passes over the crossing), and a value of 0 denotes the lower strand (which passes under the crossing).
The information returned by crossing() and strand() together pinpoint exactly which strand of the link this reference points to.