Home /Modules/array/SLRefArray.sleela

SLRefArray.sleela

lib/array/SLRefArray.sleela · 74 line(s) · sleela

<< array/SLRefArray.sleela
   SLeeLa reference-array library.
   Definition: Helpers over reference arrays Any[] (SLEELA.syntax section 46): emptiness,
   length, index check, copy, fill and identity. Version neutral (uses arrayLength). >>
#sleela 3.0
material;
class SLRefArray {
  < ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- >
  << Full descriptive record for a library-family class: identity, legality
     (metaNationalSchedule), fiduciary (copyright, trademark, corporation) and
     jurisdictional scope (metaOrigin). Values are faithful to the real origin
     of the subject where publicly known; unknown values are stated as none. >>
  String metaVersion = "1.0.0";
  int metaId = 8606;
  String metaAuthor = "Max Rupplin";
  String metaDate = "2026-11-12";
  String metaCopyright = "MEARVK LLC";
  String metaTrademark = "none";
  String metaCorporation = "MEARVK LLC";
  String metaOrigin = "International";
  String metaBirthDate = "2026-11-12";
  int metaScienceRating = 7;
  String metaNationalSchedule = "The Java Language Specification, Java SE 28 Edition (JLS 10, Arrays)";

  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; }

  < True when the value is an array handle with no elements. >
  static boolean isEmpty(Any[] a) { return arrayLength(a) == 0; }

  < Number of elements; the same as arrayLength, for code that prefers a method name. >
  static int lengthOf(Any[] a) { return arrayLength(a); }

  static void checkIndex(int index, int length) {
    if (index < 0 || index >= length) { throw new RuntimeException("array index out of range: " + index + " for length " + length); }
  }

  < A new array of n elements holding the leading elements of a; extra elements are null. >
  static Any[] copyOf(Any[] a, int n) {
    Any[] r = new Any[n];
    int m = arrayLength(a);
    if (n < m) { m = n; }
    for (int i = 0; i < m; i++) { r[i] = a[i]; }
    return r;
  }

  static void fill(Any[] a, Any v) {
    for (int i = 0; i < arrayLength(a); i++) { a[i] = v; }
  }

  < Reference identity of the arrays (the same array object), as == on arrays. >
  static boolean same(Any[] a, Any[] b) { return a == b; }
}