Previous: change Operators, Up: The change Class



3.6.4 Other functions

— Function: void change::swap (change& c);

This function swaps this change with the change given by c in an efficient manner.

— Function: int change::bells (void) const;

This returns the number of bells on which the change is defined.

— Function: int change::sign (void) const;

This returns the sign of the change: -1 if an odd number of pairs are swapped, +1 if an even number of pairs are swapped.

— Function: bool change::findswap (bell i) const;

Returns true if the change swaps bells i and i+1, and false otherwise.

— Function: bool change::findplace (bell i) const;

Returns true if the change doesn't move the bell in the ith place (i.e. if iths place is made), and false otherwise.

— Function: int change::count_places (void) const;

This function returns the number of places made in the change.

— Function: bool change::swappair (int i);

If the change doesn't currently swap bells i and i+1, then this will add that swap. If those bells are swapped, this will remove the swap. If the bells i-1 and i, or i+1 and i+2, are currently swapped, those swaps are removed.

This returns true if after the function call, the pair of bells i and i+1 are swapped, and false otherwise. If exceptions are enabled and the bell i+1 is greater the number of bells in the change, an exception of class change::out_of_range will be thrown.

This function makes it possible for the user to edit changes in such a way that they will always end up in a sensible state.

— Function: change change::reverse (void) const;

This returns the reverse of a change; that is, the change is flipped over so that on 8 bells for example, 2nds place becomes 7ths place and so on.

— Function: bool change::internal (void) const;

This returns true if the change contains internal places, and false otherwise.

— Function: string change::print (void) const;

This function prints the place notation for the change to a string.

— Function: template <> void swap<change> (change& a, change& b);

This specialised the swap function which is defined in the standard library. The result is that certain standard algorithms may become much more efficient. Note that according to your namespace setup, swap may need to be in namespace std; similarly, change may or may not be in namespace ringing. This is all taken care of.