Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ulises-jeremias committed Nov 12, 2023
1 parent 6c9f903 commit de6bfba
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions storage/cpu.v
Original file line number Diff line number Diff line change
Expand Up @@ -29,57 +29,57 @@ pub fn from_array[T](arr []T) &CpuStorage[T] {

// Private function. Used to implement Storage operator
[inline]
pub fn (storage &CpuStorage[T]) get[T](i int) T {
return storage.data[i]
pub fn (s &CpuStorage[T]) get[T](i int) T {
return s.data[i]
}

// Private function. Used to implement assigment to the Storage element
[inline]
pub fn (mut storage CpuStorage[T]) set[T](i int, val T) {
storage.data[i] = val
pub fn (mut s CpuStorage[T]) set[T](i int, val T) {
s.data[i] = val
}

// fill fills an entire storage with a given value
pub fn (mut storage CpuStorage[T]) fill[T](val T) {
for i in 0 .. storage.data.len {
storage.data[i] = val
pub fn (mut s CpuStorage[T]) fill[T](val T) {
for i in 0 .. s.data.len {
s.data[i] = val
}
}

// clone returns an independent copy of a given Storage
[inline]
pub fn (storage &CpuStorage[T]) clone[T]() &CpuStorage[T] {
pub fn (s &CpuStorage[T]) clone[T]() &CpuStorage[T] {
return &CpuStorage[T]{
data: storage.data.clone()
data: s.data.clone()
}
}

// like returns an independent copy of a given Storage
[inline]
pub fn (storage &CpuStorage[T]) like[T]() &CpuStorage[T] {
pub fn (s &CpuStorage[T]) like[T]() &CpuStorage[T] {
return &CpuStorage[T]{
data: []T{len: storage.data.len, cap: storage.data.cap}
data: []T{len: s.data.len, cap: s.data.cap}
}
}

// like_with_len returns an independent copy of a given Storage
[inline]
pub fn (storage &CpuStorage[T]) like_with_len[T](len int) &CpuStorage[T] {
mut capacity := if storage.data.cap < len { len } else { storage.data.cap }
pub fn (s &CpuStorage[T]) like_with_len[T](len int) &CpuStorage[T] {
mut capacity := if s.data.cap < len { len } else { s.data.cap }
return &CpuStorage[T]{
data: []T{len: len, cap: capacity}
}
}

pub fn (storage &CpuStorage[T]) offset[T](start int) &CpuStorage[T] {
pub fn (s &CpuStorage[T]) offset[T](start int) &CpuStorage[T] {
return &CpuStorage[T]{
data: storage.data[start..storage.data.len]
data: s.data[start..s.data.len]
}
}

[inline]
pub fn (storage &CpuStorage[T]) to_array[T]() []T {
return storage.data.clone()
pub fn (s &CpuStorage[T]) to_array[T]() []T {
return s.data.clone()
}

[inline]
Expand Down

0 comments on commit de6bfba

Please sign in to comment.