S2Cells::CellId
Inherits Comparable < Struct < Value < Object
Constants
Constructors
Conversion of from_face_ij_wrap method
Class methods
Instance methods
The comparison operator. Returns 0 if the two objects are equal,
a negative number if this object is considered less than other,
a positive number if this object is considered greater than other,
or nil if the two objects are not comparable.
Subclasses define this method to provide class-specific ordering.
The comparison operator is usually used to sort values:
# Sort in a descending way:
[3, 1, 2].sort { |x, y| y <=> x } # => [3, 2, 1]
# Sort in an ascending way:
[3, 1, 2].sort { |x, y| x <=> y } # => [1, 2, 3]
Compares this object to other based on the receiver’s <=> method,
returning true if it returns 0.
Also returns true if this and other are the same object.
def child(pos : Int) raise "Invalid cell id" unless valid? raise "Child position out of range" if leaf? new_lsb = lsb >> 2 self.class.new(@id &+ (2 * pos + 1 - 4) &* new_lsb) end
Generates an UInt64 hash value for this object.
This method must have the property that a == b implies a.hash == b.hash.
The hash value is used along with == by the Hash class to determine if two objects
reference the same hash key.
Subclasses must not override this method. Instead, they must define hash(hasher),
though usually the macro def_hash can be used to generate this method.
ToToken returns a hex-encoded string of the uint64 cell id, with leading zeros included but trailing zeros stripped.