Skip to content

Commit eed255d

Browse files
peter-jerry-yebobzhang
authored andcommitted
refactor: make arrayview immutable
1 parent 30b15c7 commit eed255d

File tree

2 files changed

+0
-96
lines changed

2 files changed

+0
-96
lines changed

array/deprecated.mbt

Lines changed: 0 additions & 44 deletions
This file was deleted.

builtin/arrayview.mbt

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -120,43 +120,6 @@ pub fn[T] ArrayView::unsafe_get(self : ArrayView[T], index : Int) -> T {
120120
self.buf()[self.start() + index]
121121
}
122122
123-
///|
124-
/// Sets the value at the specified index in the array view.
125-
///
126-
/// Parameters:
127-
///
128-
/// * `array_view` : The array view to modify.
129-
/// * `index` : The position in the array view where the value will be set.
130-
/// * `value` : The value to be assigned at the specified index.
131-
///
132-
/// Throws a panic if `index` is negative or greater than or equal to the length
133-
/// of the array view.
134-
///
135-
///
136-
#deprecated("ArrayView will be immutable, use array if you need mutation")
137-
#alias("_[_]=_")
138-
pub fn[T] ArrayView::set(self : ArrayView[T], index : Int, value : T) -> Unit {
139-
guard index >= 0 && index < self.len() else {
140-
abort(
141-
"index out of bounds: the len is from 0 to \{self.len()} but the index is \{index}",
142-
)
143-
}
144-
self.buf()[self.start() + index] = value
145-
}
146-
147-
///|
148-
#deprecated("ArrayView will be immutable, use array if you need mutation")
149-
pub fn[T] ArrayView::swap(self : ArrayView[T], i : Int, j : Int) -> Unit {
150-
guard i >= 0 && i < self.len() && j >= 0 && j < self.len() else {
151-
abort(
152-
"index out of bounds: the len is from 0 to \{self.len()} but the index is (\{i}, \{j})",
153-
)
154-
}
155-
let temp = self.buf()[self.start() + i]
156-
self.buf()[self.start() + i] = self.buf()[self.start() + j]
157-
self.buf()[self.start() + j] = temp
158-
}
159-
160123
///|
161124
/// Creates a view of a portion of the array. The view provides read-write access
162125
/// to the underlying array without copying the elements.
@@ -299,18 +262,3 @@ pub fn[T] FixedArray::sub(
299262
end - start,
300263
)
301264
}
302-
303-
///|
304-
#deprecated("ArrayView will be immutable, use array if you need mutation")
305-
pub fn[T] ArrayView::blit_to(self : ArrayView[T], dst : ArrayView[T]) -> Unit {
306-
let src_len = self.length()
307-
let dst_len = dst.length()
308-
guard dst_len >= src_len
309-
UninitializedArray::unsafe_blit(
310-
dst.buf(),
311-
dst.start(),
312-
self.buf(),
313-
self.start(),
314-
src_len,
315-
)
316-
}

0 commit comments

Comments
 (0)