Skip to content

Commit

Permalink
tidy up devec
Browse files Browse the repository at this point in the history
  • Loading branch information
Lampese committed May 3, 2024
1 parent 4b82d88 commit c5fd23a
Showing 1 changed file with 40 additions and 40 deletions.
80 changes: 40 additions & 40 deletions devec/devec.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ test "realloc" {
}

/// Return the front element from a devec, or `None` if it is empty.
///
///
/// # Example
/// ```
/// let dv = Devec::[1, 2, 3, 4, 5]
Expand All @@ -130,7 +130,7 @@ pub fn front[T](self : Devec[T]) -> Option[T] {
}

/// Return the back element from a devec, or `None` if it is empty.
///
///
/// # Example
/// ```
/// let dv = Devec::[1, 2, 3, 4, 5]
Expand All @@ -154,9 +154,9 @@ test "front_and_back" {
}

/// Adds an element to the front of the devec.
///
///
/// If the devec is at capacity, it will be reallocated.
///
///
/// # Example
/// ```
/// let dv = Devec::[1, 2, 3, 4, 5]
Expand All @@ -172,9 +172,9 @@ pub fn push_front[T](self : Devec[T], value : T) -> Unit {
}

/// Adds an element to the back of the devec.
///
///
/// If the devec is at capacity, it will be reallocated.
///
///
/// # Example
/// ```
/// let dv = Devec::[1, 2, 3, 4, 5]
Expand All @@ -190,7 +190,7 @@ pub fn push_back[T](self : Devec[T], value : T) -> Unit {
}

/// Removes a front element from a devec.
///
///
/// # Example
/// ```
/// let dv = Devec::[1, 2, 3, 4, 5]
Expand All @@ -206,7 +206,7 @@ pub fn pop_front_exn[T](self : Devec[T]) -> Unit {
}

/// Removes a back element from a devec.
///
///
/// # Example
/// ```
/// let dv = Devec::[1, 2, 3, 4, 5]
Expand All @@ -222,7 +222,7 @@ pub fn pop_back_exn[T](self : Devec[T]) -> Unit {
}

/// Removes a front element from a devec and returns it, or `None` if it is empty.
///
///
/// # Example
/// ```
/// let dv = Devec::[1, 2, 3, 4, 5]
Expand All @@ -239,7 +239,7 @@ pub fn pop_front[T](self : Devec[T]) -> Option[T] {
}

/// Removes a back element from a devec and returns it, or `None` if it is empty.
///
///
/// # Example
/// ```
/// let dv = Devec::[1, 2, 3, 4, 5]
Expand Down Expand Up @@ -291,9 +291,9 @@ test "push_realloc" {
}

/// Retrieves the element at the specified index from the devec.
///
///
/// If you try to access an index which isn’t in the Devec, it will panic.
///
///
/// # Example
/// ```
/// let dv = Devec::[1, 2, 3, 4, 5]
Expand Down Expand Up @@ -329,9 +329,9 @@ test "op_get" {
}

/// Sets the value of the element at the specified index.
///
///
/// If you try to access an index which isn’t in the Devec, it will panic.
///
///
/// # Example
/// ```
/// let dv = Devec::[1, 2, 3, 4, 5]
Expand Down Expand Up @@ -373,21 +373,21 @@ pub fn op_equal[T : Eq](self : Devec[T], other : Devec[T]) -> Bool {
}

test "op_equal" {
let dq1 = Devec::[1, 2, 3]
let dq2 = Devec::[1, 2, 3]
@assertion.assert_true(dq1 == dq2)?
let dq1 = Devec::[1, 2, 3]
let dq2 = Devec::[1, 2, 3]
dq2[0] = 2
@assertion.assert_false(dq1 == dq2)?
let dq1 = Devec::[1, 2, 3]
let dq2 = Devec::[1, 2, 3]
dq2.push_front(1)
@assertion.assert_false(dq1 == dq2)?
let dv1 = Devec::[1, 2, 3]
let dv2 = Devec::[1, 2, 3]
@assertion.assert_true(dv1 == dv2)?
let dv1 = Devec::[1, 2, 3]
let dv2 = Devec::[1, 2, 3]
dv2[0] = 2
@assertion.assert_false(dv1 == dv2)?
let dv1 = Devec::[1, 2, 3]
let dv2 = Devec::[1, 2, 3]
dv2.push_front(1)
@assertion.assert_false(dv1 == dv2)?
}

/// Iterates over the elements of the devec.
///
///
/// # Example
/// ```
/// let dv = Devec::[1, 2, 3, 4, 5]
Expand Down Expand Up @@ -424,7 +424,7 @@ test "iter2" {
}

/// Iterates over the elements of the devec with index.
///
///
/// # Example
/// ```
/// let dv = Devec::[1, 2, 3, 4, 5]
Expand Down Expand Up @@ -452,7 +452,7 @@ test "iteri" {
}

/// Iterates over the elements of the devec in reversed turn.
///
///
/// # Example
/// ```
/// let dv = Devec::[1, 2, 3, 4, 5]
Expand Down Expand Up @@ -480,7 +480,7 @@ test "iter_rev" {
}

/// Iterates over the elements of the devec in reversed turn with index.
///
///
/// # Example
/// ```
/// let dv = Devec::[1, 2, 3, 4, 5]
Expand Down Expand Up @@ -510,9 +510,9 @@ test "iter_revi" {
}

/// Clears the devec, removing all values.
///
///
/// This method has no effect on the allocated capacity of the devec, only setting the length to 0.
///
///
/// # Example
/// ```
/// let dv = Devec:: [1, 2, 3, 4, 5]
Expand All @@ -532,7 +532,7 @@ test "clear" {
}

/// Maps a function over the elements of the devec.
///
///
/// # Example
/// ```
/// let dv = Devec::[3, 4, 5]
Expand All @@ -553,7 +553,7 @@ test "map" {
}

/// Maps a function over the elements of the devec with index.
///
///
/// # Example
/// ```
/// let dv = Devec::[3, 4, 5]
Expand All @@ -574,7 +574,7 @@ test "mapi" {
}

/// Test if the devec is empty.
///
///
/// # Example
/// ```
/// let dv = Devec::new()
Expand All @@ -592,7 +592,7 @@ test "is_empty" {
}

/// Search the devec index for a given element.
///
///
/// # Example
/// ```
/// let dv = Devec::[3, 4, 5]
Expand All @@ -616,7 +616,7 @@ test "search" {
}

/// Checks if the vector contains an element.
///
///
/// # Example
/// ```
/// let dv = Devec::[3, 4, 5]
Expand All @@ -641,9 +641,9 @@ test "contains" {

/// Reserves capacity to ensure that it can hold at least the number of elements
/// specified by the `capacity` argument.
///
///
/// # Example
///
///
/// ```
/// let dv = Devec::[1]
/// dv.reserve_capacity(10)
Expand Down Expand Up @@ -685,9 +685,9 @@ test "reserve_capacity_2" {
}

/// Shrinks the capacity of the devec as much as possible.
///
///
/// # Example
///
///
/// ```
/// let dv = Devec::with_capacity(10)
/// dv.push_back(1)
Expand Down

0 comments on commit c5fd23a

Please sign in to comment.