Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

[move-stdlib] fix vector docs #414

Merged
merged 2 commits into from
Aug 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion language/move-stdlib/docs/vector.md
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ Return <code><b>true</b></code> if the vector <code>v</code> has no elements and
## Function `contains`

Return true if <code>e</code> is in the vector <code>v</code>.
Otherwise, returns false.


<pre><code><b>public</b> <b>fun</b> <a href="vector.md#0x1_vector_contains">contains</a>&lt;Element&gt;(v: &<a href="vector.md#0x1_vector">vector</a>&lt;Element&gt;, e: &Element): bool
Expand Down Expand Up @@ -542,7 +543,7 @@ Aborts if <code>i</code> is out of bounds.

## Function `swap_remove`

Swap the <code>i</code>th element of the vector <code>v</code> with the last element and then pop the vector.
Swap the <code>i</code>th element of the vector <code>v</code> with the last element and then pop the element.
This is O(1), but does not preserve ordering of elements in the vector.
Aborts if <code>i</code> is out of bounds.

Expand Down
3 changes: 2 additions & 1 deletion language/move-stdlib/sources/vector.move
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ module std::vector {
}

/// Return true if `e` is in the vector `v`.
/// Otherwise, returns false.
public fun contains<Element>(v: &vector<Element>, e: &Element): bool {
let i = 0;
let len = length(v);
Expand Down Expand Up @@ -145,7 +146,7 @@ module std::vector {
pragma intrinsic = true;
}

/// Swap the `i`th element of the vector `v` with the last element and then pop the vector.
/// Swap the `i`th element of the vector `v` with the last element and then pop the element.
/// This is O(1), but does not preserve ordering of elements in the vector.
/// Aborts if `i` is out of bounds.
public fun swap_remove<Element>(v: &mut vector<Element>, i: u64): Element {
Expand Down