1  package frost.collections
 2  
 3  ====================================================================================================
 4  A write-only view of a list of elements. `ListWriter` adds random-access methods to the basic
 5  functionality inherited from [CollectionWriter].
 6  
 7  @see ListView
 8  @see List
 9  ====================================================================================================
10  interface ListWriter<T> : CollectionWriter<T> {
11      ================================================================================================
12      Replaces the element at `index` with a new value.
13  
14      @param index the element to modify
15      @param value the new value
16      ================================================================================================
17      @pre(index >= 0 & index < count)< count)
18      method []:=(index:Int, value:T)
19  
20      ================================================================================================
21      Inserts a new element at `index`, moving all elements from `index` to the end of the list out of
22      the way to make room for it. Inserting with an `index` equal to `count` is equivalent to calling
23      [add].
24  
25      @param index the location at which to insert
26      @param value the new value
27      ================================================================================================
28      @pre(index >= 0 & index <= count)
29      method insert(index:Int, value:T)
30  
31      ================================================================================================
32      Removes the element at `index`, moving all elements from `index + 1` to the end of the list down
33      one index to fill in the "hole" created by the deletion.
34  
35      @param index the index to remove
36      @returns the value which was removed
37      ================================================================================================
38      @pre(index >= 0 & index < count)< count)
39      method removeIndex(index:Int):T
40  
41      @pre(count > 0)
42      @default
43      method removeLast() {
44          removeIndex(count - 1)
45      }
46  }
47