Category talk:Wren-array: Difference between revisions

→‎Source code: Changes to BitArrray indexer methods.
(Added a BitArray class.)
(→‎Source code: Changes to BitArrray indexer methods.)
Line 195:
// Gets the element at 'index'. If index is negative, it counts backwards
// from the end of the array where -1 is the last element.
// To maximize access speed, this method doesn't validate the index.
// Use the 'get' method instead if you need to do that.
[index] {
Check.int("index", index, -count, count-1)
if (index < 0) index = count + index
var ix = (index/32).floor
Line 204 ⟶ 205:
 
// Sets the element at 'index'. Negative indices are treated as in the getter.
// To maximize access speed, this method doesn't validate the index nor the new value.
// Use the 'set' method instead if you need to do that.
[index]=(v) {
Check.int("index", index, -count, count-1)
if (index < 0) index = count + index
var ix = (index/32).floor
Line 212 ⟶ 214:
}
 
// As [index] method but validates the index.
get(index) {
Check.int("index", index, -count, count-1)
return this[index]
}
 
// As [index]=(v) method but validates the index and the new value.
set(index, v) {
Check.int("index", index, -count, count-1)
Check.bool("value", v)
this[index] = v
}
// Returns a List<Bool> using the normal 8 bytes for each element.
toList {
9,485

edits