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

logo

Cello High Level C

Methods

get

var get(var self, var key);

Get the value at a given key for object self.

set

void set(var self, var key, var val);

Set the value at a given key for object self.

mem

bool mem(var self, var key);

Returns true if key is a member of the object self.

rem

void rem(var self, var key);

Removes the key from object self.

key_type

var key_type(var self);

Returns the key type for the object self.

val_type

var val_type(var self);

Returns the value type for the object self.

Examples

Usage 1

var x = new(Array, String, 
  $S("Hello"), $S("There"));

show(get(x, $I(0))); /* Hello */
show(get(x, $I(1))); /* There */
set(x, $I(1), $S("Blah"));
show(get(x, $I(1))); /* Blah */

Usage 2

var prices = new(Table, String, Int, 
  $S("Apple"),  $I(12),
  $S("Banana"), $I( 6),
  $S("Pear"),   $I(55));

var pear_price   = get(prices, $S("Pear"));
var banana_price = get(prices, $S("Banana"));
var apple_price  = get(prices, $S("Apple"));

show(pear_price);   /* 55 */
show(banana_price); /*  6 */
show(apple_price);  /* 12 */

Get


Gettable or Settable

The Get class provides a method to get or set certain properties of an object using keys and value. Typically it is implemented by data lookup structures such as Table or Map but it is also used more generally such as using indices to look up items in Array, or as thread local storage for the Thread object.

Definition

struct Get {
  var  (*get)(var, var);
  void (*set)(var, var, var);
  bool (*mem)(var, var);
  void (*rem)(var, var);
  var (*key_type)(var);
  var (*val_type)(var);
};

Implementers

  • Array |     Sequential Container
  • Filter |     Filtered Iterable
  • GC |     Garbage Collector
  • List |     Linked List
  • Map |     Apply Function to Iterable
  • Range |     Integer Sequence
  • Slice |     Partial Iterable
  • String |     String Object
  • Table |     Hash table
  • Thread |     Concurrent Execution
  • Tree |     Balanced Binary Tree
  • Tuple |     Basic Collection
  • Zip |     Multiple Iterator

Back