User Tools

Site Tools


01_user_documentation:07_rgg_xl:02_xl:10_rgg_addition:04_operator_overload:collection

Table of Contents

Collections

Collections of the type java.util.List, and all the list in xl.lang. : BooleanList, IntList, … ObjectList, have the operator shl overloaded.

SHL

  • List << Object add the object to the list
  • List << primitive add the primitive to the list

e.g. :

de.grogra.xl.util.ObjectList list = new ObjectList();
list << new Sphere() << new Box(); // add a sphere and a box objects to the objectlist
 
java.util.List list2 = new ArrayList();
list2 << 5 << 2 <<1; // add 5, 2, and 1 to the list.

In

  • Object in Collection return true if the collection contains the object
println( new Sphere() in list) ; // false the new Sphere is not the same a the previous new Sphere();
println( 5 in list2) ; // true

Index

  • xl.util.XXList[index] get the index-th element of that list. XXList are list defined in xl.util package: IntList, BooleanList, …
de.grogra.xl.util.IntList l = new IntList();
l << 1 << 5 << 3 << 1 << 54;
println( l[3]); // print "3", the index starts at 0;
01_user_documentation/07_rgg_xl/02_xl/10_rgg_addition/04_operator_overload/collection.txt · Last modified: 2025/08/20 10:32 by gaetan