<< lib/collections/SLSet.sleela SLeeLa Standard Library Definition. Definition: A concrete, String-valued set with no duplicate members, backed by the VM-managed growable native array. Membership and insertion are linear scans (suited to small-to-moderate sets); order of iteration is insertion order. This first implementation deliberately avoids Generics. >> #sleela 2.5 material; < Unified SLeeLa standard-library front-end object. > < Family: collections. Native VM/OS work crosses an explicit bridge. > class SLSet { << ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- Eleven catalogued attributes with getter/setter pairs, so a GUI, loader, or catalog can read and (where appropriate) override this record. Values are faithful to the subject real origin where publicly known. >> String metaVersion = "1.1.0"; int metaId = 835; String metaAuthor = "Max Rupplin vs. Dr. Mrs. Elisabeth Harkins"; String metaDate = "2026-11-04"; String metaCopyright = "SLeeLa project"; String metaTrademark = "none"; String metaCorporation = "none"; < metaOrigin: National | | International | Galactic > String metaOrigin = "International"; String metaBirthDate = "2026-09-28"; < metaScienceRating: maturity/robustness on a 1..10 scale > int metaScienceRating = 9; < metaNationalSchedule: a real, citable instrument or "none" > String metaNationalSchedule = "none"; String getMetaVersion() { return metaVersion; } void setMetaVersion(String v) { metaVersion = v; } int getMetaId() { return metaId; } void setMetaId(int v) { metaId = v; } String getAuthor() { return metaAuthor; } void setAuthor(String v) { metaAuthor = v; } String getDate() { return metaDate; } void setDate(String v) { metaDate = v; } String getCopyright() { return metaCopyright; } void setCopyright(String v) { metaCopyright = v; } String getTrademark() { return metaTrademark; } void setTrademark(String v) { metaTrademark = v; } String getCorporation() { return metaCorporation; } void setCorporation(String v) { metaCorporation = v; } String getOrigin() { return metaOrigin; } void setOrigin(String v) { metaOrigin = v; } String getBirthDate() { return metaBirthDate; } void setBirthDate(String v) { metaBirthDate = v; } int getScienceRating() { return metaScienceRating; } void setScienceRating(int v) { metaScienceRating = v; } String getNationalSchedule() { return metaNationalSchedule; } void setNationalSchedule(String v) { metaNationalSchedule = v; } << Backing storage uses the VM-managed, growable String array. size is the count of distinct members; values[0..size) are the members. >> String[] values = new String[0]; int size = 0; << Index of a member, or -1 when absent. null is matched by passing null, so the set admits at most one null member. >> int indexOf(String value) { int i = 0; while (i < size) { String current = arrayGet(values, i); if (current == null) { if (value == null) { return i; } } else { if (current == value) { return i; } } i = i + 1; } return -1; } < True when value is a member. > boolean contains(String value) { return indexOf(value) >= 0; } << Insert value if absent. Returns true when the set grew, false when the value was already present. >> boolean add(String value) { if (indexOf(value) >= 0) { return false; } if (size < arrayLength(values)) { arraySet(values, size, value); } else { arrayPush(values, value); } size = size + 1; return true; } << Remove value if present, preserving the order of remaining members. Returns true when a member was removed. >> boolean discard(String value) { int at = indexOf(value); if (at < 0) { return false; } int i = at; while (i + 1 < size) { arraySet(values, i, arrayGet(values, i + 1)); i = i + 1; } size = size - 1; arraySet(values, size, null); return true; } < Member at the given insertion-order index, or null when out of range. > String at(int index) { if (index < 0 || index >= size) { return null; } return arrayGet(values, index); } < Compatibility convenience: drop one member (the last), if present. > void remove() { if (size > 0) { size = size - 1; arraySet(values, size, null); } } < Drop every member; capacity remains available for reuse. > void clear() { while (size > 0) { size = size - 1; arraySet(values, size, null); } } int length() { return size; } boolean empty() { return size == 0; } }