« Home » « Learn » « Download » « Github »

logo

Cello High Level C

Methods

swap

void swap(var self, var obj);

Swap the object self for the object obj.

Examples

Usage

var x = $S("Hello");
var y = $S("World");
show(x); /* Hello */
show(y); /* World */
swap(x, y);
show(x); /* World */
show(y); /* Hello */

Swap


Swapable

The Swap class can be used to override the behaviour of swapping two objects. By default the Swap class simply swaps the memory of the two objects passed in as parameters making use of the Size class. In almost all cases this default behaviour should be fine, even if the objects have custom assignment functions.

Swapping can be used internally by various collections and algorithms.

Definition

struct Swap {
  void (*swap)(var, var);
};

Derivers

  • Array |     Sequential Container
  • Box |     Unique Pointer
  • Exception |     Exception Object
  • File |     Operating System File
  • Filter |     Filtered Iterable
  • Float |     Floating Point Object
  • Function |     Function Object
  • GC |     Garbage Collector
  • Int |     Integer Object
  • List |     Linked List
  • Map |     Apply Function to Iterable
  • Mutex |     Mutual Exclusion Lock
  • Process |     Operating System Process
  • Range |     Integer Sequence
  • Ref |     Shared Pointer
  • Slice |     Partial Iterable
  • String |     String Object
  • Table |     Hash table
  • Thread |     Concurrent Execution
  • Tree |     Balanced Binary Tree
  • Tuple |     Basic Collection
  • Type |     Metadata Object
  • Zip |     Multiple Iterator

Implementers


Back