greenhouse
a creative coding toolkit for spatial interfaces

Trove

A list of elements.

The element type must have a no-argument constructor, a copy constructor, and an operator==.

  • Trove ()
  • Append ()
  • Remove ()
  • RemoveNth ()
  • Count ()
  • Nth ()
  • Find ()
  • Insert ()
  • Empty ()
  • TroveFromIngest ()
  • AsStr ()

Example

#define WORKER
#include "Greenhouse.h"

void Setup ()
{ Trove <int64> t;

  t . Append (1);
  t . Append (2);
  t . Append (3);
  INFORM (ToStr (t));   // result is [1, 2, 3]

  t . Remove (2);
  INFORM (ToStr (t));   // result is [1, 3]

  t . RemoveNth (1);
  INFORM (ToStr (t));   // result is [1]

  INFORM ("Num items = " + ToStr(t . Count ())); // 1

  t . Append (9);

  INFORM ("value of t[0] = " + ToStr (t[0]));  // 1
  INFORM ("value of t[-1] = " + ToStr (t[-1]));  // 9
  INFORM ("value of t[10] = " + ToStr (t[10]));  // ?

  INFORM ("index of 9 = " + ToStr (t . Find (9)));  // 1

  t . Insert (0, 0);  // make t [-7, 0, 9]
  INFORM (t . AsStr ());

  // empty the trove
  t . Empty ();

  Protein p = Protein (Slaw::List ("descrip1", "descrip2"),
                       Slaw::Map ("some_integers",
                                  Slaw::List (1, 2, 3, 4, 5)));
  // t will be [1, 2, 3, 4, 5]
  t = TroveFromIngest <int64> (p, "some_integers");
}