Skip to content

Commit

Permalink
std::vec: add the clear method to the Vec[T]
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Jan 31, 2024
1 parent 94f78de commit d32baa8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions std/vec/vec.jule
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ impl Vec {
}
}

// Removes all elements.
// Does not deallocates buffer, keeps capacity.
pub fn clear(mut self) {
self.mem.buff.len = 0
}

// Push item to end of heap.
pub fn push(mut self, mut item: T) {
if self.len() >= self.cap() {
Expand Down

0 comments on commit d32baa8

Please sign in to comment.