• Effekt Logo Effekt Library
    • resizable_array
      • ResizableArray
      • growFactor
      • shrinkThreshold
      • size
      • resizableArray
      • resizableArray
      • boundsCheck
      • get
      • set
      • swap
      • setCapacity
      • maybeShrink
      • ensureCapacity
      • setResizing
      • add
      • popRight
      • foreach
      • foreach
      • foreachIndex
      • foreachIndex
      • foreachReversed
      • foreachReversed
      • foreachIndexReversed
      • foreachIndexReversed
      • toList
      • each
      • feed
      • collect
      • returning
        • collect
    • resizable_array
    • Jump to source: libraries/common/resizable_array.effekt
      Example usage: examples/stdlib/resizable_array
      • ResizableArray [T] (rawSizePtr: Ref[Int], rawContentPtr: Ref[Array[T]])
      • A resizable array, implemented as a wrapper around a mutable array and a size field.
      • growFactor
      • Factor by which to grow the capacity when it becomes too small
      • shrinkThreshold
      • shrink array when size / capacity falls below this threshold
        should be < 1/growFactor
      • size [T] (arr: ResizableArray[T])
      • Number of elements in the dynamic array
        
        O(1)
      • resizableArray [T] (capacity: Int): ResizableArray[T] / {}
      • Allocate a new, empty dynamic array with given initial capacity
      • resizableArray [T]: ResizableArray[T] / {}
      • Allocate a new, empty dynamic array
      • boundsCheck [T] (arr: ResizableArray[T], index: Int): Unit / {Exception[OutOfBounds]}
      • Throw an OutOfBounds exception if index is not a valid index into arr
      • get [T] (arr: ResizableArray[T], index: Int): T / {Exception[OutOfBounds]}
      • Get the element at position `index` in the resizable array `arr`
        
        O(1)
      • set [T] (arr: ResizableArray[T], index: Int, value: T): Unit / {Exception[OutOfBounds]}
      • Set the element at position `index` in the resizable array `arr` to `value`
        
        O(1)
      • swap [T] (arr: ResizableArray[T], index1: Int, index2: Int): Unit / {Exception[OutOfBounds]}
      • Swap the elements at the given positions in the resizable array `arr`
        
        O(1)
      • setCapacity [T] (arr: ResizableArray[T], capacity: Int): Unit / {Exception[OutOfBounds]}
      • Change the resizable array to have exactly the given capacity.
        This only changes the size of the backing array, not the `size`.
        
        O(n)
      • maybeShrink [T] (arr: ResizableArray[T]): Unit / {Exception[OutOfBounds]}
      • If the shrinkThreshold is reached, shrink by growFactor, otherwise do nothing
        
        O(n)
      • ensureCapacity [T] (arr: ResizableArray[T], capacity: Int): Unit / {Exception[OutOfBounds]}
      • Makes sure capacity is at least the given one
        
        O(given capacity - current capacity) amortized, O(n) worst case // TODO ?
      • setResizing [T] (arr: ResizableArray[T], index: Int, value: T): Unit / {Exception[OutOfBounds]}
      • Set the value at given position, resizing if necessary
        Note: New elements might be uninitialized!!!
        
        O(max(1,index - n)) amortized, O(n) worst case if index > capacity
      • add [T] (arr: ResizableArray[T], value: T): Int / {}
      • Add a new element at the end of the resizable array.
        Return the index of the new element
        
        O(1) amortized, O(n) worst case
      • popRight [T] (arr: ResizableArray[T]): T / {Exception[OutOfBounds]}
      • Remove and return the rightmost element in the resizable array.
        
        O(1) amortized, O(n) worst case
      • foreach [T] (arr: ResizableArray[T]) { action: (T) => Unit }: Unit / {}
      • Traverse the resizable array `arr`, applying the given action on every element.
      • foreach [T] (arr: ResizableArray[T]) { action: (T){Label} => Unit }: Unit / {}
      • Traverse the resizable array `arr`, applying the given action on every element,
        providing a `label` for `break`/`continue`.
      • foreachIndex [T] (arr: ResizableArray[T]) { action: (Int, T) => Unit }: Unit / {}
      • Traverse the resizable array `arr`, applying the given action on every element and its (zero-based) index.
      • foreachIndex [T] (arr: ResizableArray[T]) { action: (Int, T){Label} => Unit }: Unit / {}
      • Traverse the resizable array `arr`, applying the given action on every element and its (zero-based) index,
        providing a `label` for `break`/`continue`.
      • foreachReversed [T] (arr: ResizableArray[T]) { action: (T) => Unit }: Unit / {}
      • Traverse the resizable array `arr` in reverse order, applying the given action on every element.
      • foreachReversed [T] (arr: ResizableArray[T]) { action: (T){Label} => Unit }: Unit / {}
      • Traverse the resizable array `arr` in reverse order, applying the given action on every element,
        providing a `label` for `break`/`continue`.
      • foreachIndexReversed [T] (arr: ResizableArray[T]) { action: (Int, T) => Unit }: Unit / {}
      • Traverse the resizable array `arr` in reverse order, applying the given action on every element and its (zero-based) index.
      • foreachIndexReversed [T] (arr: ResizableArray[T]) { action: (Int, T){Label} => Unit }: Unit / {}
      • Traverse the resizable array `arr` in reverse order, applying the given action on every element and its (zero-based) index,
        providing a `label` for `break`/`continue`.
      • toList [T] (arr: ResizableArray[T]): List[T] / {}
      • Create a new list from a given resizable array `arr`.
      • each [T] (arr: ResizableArray[T]): Unit / {emit[T]}
      • Turns `arr` into a producer of a push stream
        by emitting each contained value from 0 to length - 1.
      • feed [R, T] (arr: ResizableArray[T]) { reader: => R / {read[T]} }: R / {}
      • Connects `arr` as a producer to a given pull stream `reader` acting as a consumer.
      • collect [T] { stream: => Unit / {emit[T]} }: ResizableArray[T] / {}
      • Collects elements emitted by a push stream producer `stream` into a new resizable array,
        discarding the result of the producer.
      • returning
        • collect [T, R] { stream: => R / {emit[T]} }: Tuple2[R, ResizableArray[T]] / {}
        • Collects elements emitted by a push stream producer `stream` into a new resizable array,
          returning the result of the producer as well as the collected array.