• Effekt Logo Effekt Library
    • resizable_array
      • ResizableArray
      • growFactor
      • shrinkThreshold
      • size
      • resizableArray
      • resizableArray
      • boundsCheck
      • unsafeGet
      • get
      • unsafeSet
      • set
      • unsafeSwap
      • swap
      • unsafeSetCapacity
      • setCapacity
      • maybeShrink
      • ensureCapacity
      • setResizing
      • add
      • popRight
      • foreachIndex
      • foreachIndex
      • foreach
      • foreach
      • foreachIndexReversed
      • foreachIndexReversed
      • foreachReversed
      • foreachReversed
      • toList
    • 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]])
      • 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
      • unsafeGet [T] (arr: ResizableArray[T], index: Int): T / {}
      • get the element at position index in the array
        
        precondition: index is a valid index into the array
        
        O(1)
      • get [T] (arr: ResizableArray[T], index: Int): T / {Exception[OutOfBounds]}
      • get the element at position index in the array
        
        O(1)
      • unsafeSet [T] (arr: ResizableArray[T], index: Int, value: T): Unit / {}
      • set the element at position index in the array
        
        precondition: index is a valid index into the array
        
        O(1)
      • set [T] (arr: ResizableArray[T], index: Int, value: T): Unit / {Exception[OutOfBounds]}
      • set the element at position index in the array
        
        O(1)
      • unsafeSwap [T] (arr: ResizableArray[T], index1: Int, index2: Int): Unit / {}
      • swap the elements at the given positions in the array
        
        precondition: both are valid indices into the array
        
        O(1)
      • swap [T] (arr: ResizableArray[T], index1: Int, index2: Int): Unit / {Exception[OutOfBounds]}
      • swap the elements at the given positions in the array
        
        O(1)
      • unsafeSetCapacity [T] (arr: ResizableArray[T], capacity: Int): Unit / {}
      • Change the dynamic to have exactly the given capacity
        
        precondition: given capacity is at least the size of the array
        
        O(n)
      • 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 / {}
      • 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
      • foreachIndex [T] (arr: ResizableArray[T]) { body: (Int, T) => Unit }: Unit / {}
      • foreachIndex [T] (arr: ResizableArray[T]) { body: (Int, T){Control} => Unit }: Unit / {}
      • foreach [T] (arr: ResizableArray[T]) { body: (T) => Unit }: Unit / {}
      • foreach [T] (arr: ResizableArray[T]) { body: (T){Control} => Unit }: Unit / {}
      • foreachIndexReversed [T] (arr: ResizableArray[T]) { body: (Int, T){Control} => Unit }: Unit / {}
      • foreachIndexReversed [T] (arr: ResizableArray[T]) { body: (Int, T) => Unit }: Unit / {}
      • foreachReversed [T] (arr: ResizableArray[T]) { body: (T){Control} => Unit }: Unit / {}
      • foreachReversed [T] (arr: ResizableArray[T]) { body: (T) => Unit }: Unit / {}
      • toList [T] (arr: ResizableArray[T]): List[T] / {}