pub struct GenericVector<A, P>where
P: SharedPointerKind,{ /* private fields */ }
Expand description
A persistent vector.
This is a sequence of elements in insertion order - if you need a list of things, any kind of list of things, this is what you’re looking for.
It’s implemented as an RRB vector with smart head/tail
chunking. In performance terms, this means that practically
every operation is O(log n), except push/pop on both sides, which will be
O(1) amortised, and O(log n) in the worst case. In practice, the push/pop
operations will be blindingly fast, nearly on par with the native
VecDeque
, and other operations will have decent, if not high,
performance, but they all have more or less the same O(log n) complexity, so
you don’t need to keep their performance characteristics in mind -
everything, even splitting and merging, is safe to use and never too slow.
§Performance Notes
Because of the head/tail chunking technique, until you push a number of
items above double the tree’s branching factor (that’s self.len()
= 2 ×
k (where k = 64) = 128) on either side, the data structure is still just
a handful of arrays, not yet an RRB tree, so you’ll see performance and
memory characteristics similar to Vec
or VecDeque
.
This means that the structure always preallocates four chunks of size k
(k being the tree’s branching factor), equivalent to a Vec
with
an initial capacity of 256. Beyond that, it will allocate tree nodes of
capacity k as needed.
In addition, vectors start out as single chunks, and only expand into the
full data structure once you go past the chunk size. This makes them
perform identically to Vec
at small sizes.
Implementations§
Source§impl<A, P> GenericVector<A, P>where
P: SharedPointerKind,
impl<A, P> GenericVector<A, P>where
P: SharedPointerKind,
Sourcepub fn new() -> GenericVector<A, P>
pub fn new() -> GenericVector<A, P>
Construct an empty vector.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Get the length of a vector.
Time: O(1)
§Examples
let vec: Vector<i64> = vector![1, 2, 3, 4, 5];
assert_eq!(5, vec.len());
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Test whether a vector is empty.
Time: O(1)
§Examples
let vec = vector!["Joe", "Mike", "Robert"];
assert_eq!(false, vec.is_empty());
assert_eq!(true, Vector::<i64>::new().is_empty());
Sourcepub fn is_inline(&self) -> bool
pub fn is_inline(&self) -> bool
Test whether a vector is currently inlined.
Vectors small enough that their contents could be stored entirely inside
the space of std::mem::size_of::<GenericVector<A, P>>()
bytes are stored inline on
the stack instead of allocating any chunks. This method returns true
if
this vector is currently inlined, or false
if it currently has chunks allocated
on the heap.
This may be useful in conjunction with ptr_eq()
, which checks if
two vectors’ heap allocations are the same, and thus will never return true
for inlined vectors.
Time: O(1)
Sourcepub fn ptr_eq(&self, other: &GenericVector<A, P>) -> bool
pub fn ptr_eq(&self, other: &GenericVector<A, P>) -> bool
Test whether two vectors refer to the same content in memory.
This uses the following rules to determine equality:
- If the two sides are references to the same vector, return true.
- If the two sides are single chunk vectors pointing to the same chunk, return true.
- If the two sides are full trees pointing to the same chunks, return true.
This would return true if you’re comparing a vector to itself, or
if you’re comparing a vector to a fresh clone of itself. The exception to this is
if you’ve cloned an inline array (ie. an array with so few elements they can fit
inside the space a Vector
allocates for its pointers, so there are no heap allocations
to compare).
Time: O(1)
Sourcepub fn leaves(&self) -> Chunks<'_, A, P> ⓘ
pub fn leaves(&self) -> Chunks<'_, A, P> ⓘ
Get an iterator over the leaf nodes of a vector.
This returns an iterator over the Chunk
s at the leaves of the
RRB tree. These are useful for efficient parallelisation of work on
the vector, but should not be used for basic iteration.
Time: O(1)
Sourcepub fn get(&self, index: usize) -> Option<&A>
pub fn get(&self, index: usize) -> Option<&A>
Get a reference to the value at index index
in a vector.
Returns None
if the index is out of bounds.
Time: O(log n)
§Examples
let vec = vector!["Joe", "Mike", "Robert"];
assert_eq!(Some(&"Robert"), vec.get(2));
assert_eq!(None, vec.get(5));
Sourcepub fn front(&self) -> Option<&A>
pub fn front(&self) -> Option<&A>
Get the first element of a vector.
If the vector is empty, None
is returned.
Time: O(log n)
Sourcepub fn head(&self) -> Option<&A>
pub fn head(&self) -> Option<&A>
Get the first element of a vector.
If the vector is empty, None
is returned.
This is an alias for the front
method.
Time: O(log n)
Sourcepub fn back(&self) -> Option<&A>
pub fn back(&self) -> Option<&A>
Get the last element of a vector.
If the vector is empty, None
is returned.
Time: O(log n)
Sourcepub fn last(&self) -> Option<&A>
pub fn last(&self) -> Option<&A>
Get the last element of a vector.
If the vector is empty, None
is returned.
This is an alias for the back
method.
Time: O(log n)
Sourcepub fn index_of(&self, value: &A) -> Option<usize>where
A: PartialEq,
pub fn index_of(&self, value: &A) -> Option<usize>where
A: PartialEq,
Get the index of a given element in the vector.
Searches the vector for the first occurrence of a given value,
and returns the index of the value if it’s there. Otherwise,
it returns None
.
Time: O(n)
§Examples
let mut vec = vector![1, 2, 3, 4, 5];
assert_eq!(Some(2), vec.index_of(&3));
assert_eq!(None, vec.index_of(&31337));
Sourcepub fn contains(&self, value: &A) -> boolwhere
A: PartialEq,
pub fn contains(&self, value: &A) -> boolwhere
A: PartialEq,
Test if a given element is in the vector.
Searches the vector for the first occurrence of a given value,
and returns true
if it’s there. If it’s nowhere to be found
in the vector, it returns false
.
Time: O(n)
§Examples
let mut vec = vector![1, 2, 3, 4, 5];
assert_eq!(true, vec.contains(&3));
assert_eq!(false, vec.contains(&31337));
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Discard all elements from the vector.
This leaves you with an empty vector, and all elements that were previously inside it are dropped.
Time: O(n)
Sourcepub fn binary_search_by<F>(&self, f: F) -> Result<usize, usize>
pub fn binary_search_by<F>(&self, f: F) -> Result<usize, usize>
Binary search a sorted vector for a given element using a comparator function.
Assumes the vector has already been sorted using the same comparator
function, eg. by using sort_by
.
If the value is found, it returns Ok(index)
where index
is the index
of the element. If the value isn’t found, it returns Err(index)
where
index
is the index at which the element would need to be inserted to
maintain sorted order.
Time: O(log n)
Sourcepub fn binary_search(&self, value: &A) -> Result<usize, usize>where
A: Ord,
pub fn binary_search(&self, value: &A) -> Result<usize, usize>where
A: Ord,
Binary search a sorted vector for a given element.
If the value is found, it returns Ok(index)
where index
is the index
of the element. If the value isn’t found, it returns Err(index)
where
index
is the index at which the element would need to be inserted to
maintain sorted order.
Time: O(log n)
Sourcepub fn binary_search_by_key<B, F>(&self, b: &B, f: F) -> Result<usize, usize>
pub fn binary_search_by_key<B, F>(&self, b: &B, f: F) -> Result<usize, usize>
Binary search a sorted vector for a given element with a key extract function.
Assumes the vector has already been sorted using the same key extract
function, eg. by using sort_by_key
.
If the value is found, it returns Ok(index)
where index
is the index
of the element. If the value isn’t found, it returns Err(index)
where
index
is the index at which the element would need to be inserted to
maintain sorted order.
Time: O(log n)
Sourcepub fn unit(a: A) -> GenericVector<A, P>
pub fn unit(a: A) -> GenericVector<A, P>
Construct a vector with a single value.
§Examples
let vec = Vector::unit(1337);
assert_eq!(1, vec.len());
assert_eq!(
vec.get(0),
Some(&1337)
);
Source§impl<A, P> GenericVector<A, P>where
A: Clone,
P: SharedPointerKind,
impl<A, P> GenericVector<A, P>where
A: Clone,
P: SharedPointerKind,
Sourcepub fn get_mut(&mut self, index: usize) -> Option<&mut A>
pub fn get_mut(&mut self, index: usize) -> Option<&mut A>
Get a mutable reference to the value at index index
in a
vector.
Returns None
if the index is out of bounds.
Time: O(log n)
§Examples
let mut vec = vector!["Joe", "Mike", "Robert"];
{
let robert = vec.get_mut(2).unwrap();
assert_eq!(&mut "Robert", robert);
*robert = "Bjarne";
}
assert_eq!(vector!["Joe", "Mike", "Bjarne"], vec);
Sourcepub fn front_mut(&mut self) -> Option<&mut A>
pub fn front_mut(&mut self) -> Option<&mut A>
Get a mutable reference to the first element of a vector.
If the vector is empty, None
is returned.
Time: O(log n)
Sourcepub fn back_mut(&mut self) -> Option<&mut A>
pub fn back_mut(&mut self) -> Option<&mut A>
Get a mutable reference to the last element of a vector.
If the vector is empty, None
is returned.
Time: O(log n)
Sourcepub fn focus_mut(&mut self) -> FocusMut<'_, A, P>
pub fn focus_mut(&mut self) -> FocusMut<'_, A, P>
Construct a FocusMut
for a vector.
Time: O(1)
Sourcepub fn iter_mut(&mut self) -> IterMut<'_, A, P> ⓘ
pub fn iter_mut(&mut self) -> IterMut<'_, A, P> ⓘ
Get a mutable iterator over a vector.
Time: O(1)
Sourcepub fn leaves_mut(&mut self) -> ChunksMut<'_, A, P> ⓘ
pub fn leaves_mut(&mut self) -> ChunksMut<'_, A, P> ⓘ
Get a mutable iterator over the leaf nodes of a vector.
This returns an iterator over the Chunk
s at the leaves of the
RRB tree. These are useful for efficient parallelisation of work on
the vector, but should not be used for basic iteration.
Time: O(1)
Sourcepub fn update(&self, index: usize, value: A) -> GenericVector<A, P>
pub fn update(&self, index: usize, value: A) -> GenericVector<A, P>
Create a new vector with the value at index index
updated.
Panics if the index is out of bounds.
Time: O(log n)
§Examples
let mut vec = vector![1, 2, 3];
assert_eq!(vector![1, 5, 3], vec.update(1, 5));
Sourcepub fn set(&mut self, index: usize, value: A) -> A
pub fn set(&mut self, index: usize, value: A) -> A
Update the value at index index
in a vector.
Returns the previous value at the index.
Panics if the index is out of bounds.
Time: O(log n)
Sourcepub fn swap(&mut self, i: usize, j: usize)
pub fn swap(&mut self, i: usize, j: usize)
Swap the elements at indices i
and j
.
Time: O(log n)
Sourcepub fn push_front(&mut self, value: A)
pub fn push_front(&mut self, value: A)
Push a value to the front of a vector.
Time: O(1)*
§Examples
let mut vec = vector![5, 6, 7];
vec.push_front(4);
assert_eq!(vector![4, 5, 6, 7], vec);
Sourcepub fn push_back(&mut self, value: A)
pub fn push_back(&mut self, value: A)
Push a value to the back of a vector.
Time: O(1)*
§Examples
let mut vec = vector![1, 2, 3];
vec.push_back(4);
assert_eq!(vector![1, 2, 3, 4], vec);
Sourcepub fn pop_front(&mut self) -> Option<A>
pub fn pop_front(&mut self) -> Option<A>
Remove the first element from a vector and return it.
Time: O(1)*
§Examples
let mut vec = vector![1, 2, 3];
assert_eq!(Some(1), vec.pop_front());
assert_eq!(vector![2, 3], vec);
Sourcepub fn pop_back(&mut self) -> Option<A>
pub fn pop_back(&mut self) -> Option<A>
Remove the last element from a vector and return it.
Time: O(1)*
§Examples
let mut vec = vector![1, 2, 3];
assert_eq!(Some(3), vec.pop_back());
assert_eq!(vector![1, 2], vec);
Sourcepub fn append(&mut self, other: GenericVector<A, P>)
pub fn append(&mut self, other: GenericVector<A, P>)
Append the vector other
to the end of the current vector.
Time: O(log n)
§Examples
let mut vec = vector![1, 2, 3];
vec.append(vector![7, 8, 9]);
assert_eq!(vector![1, 2, 3, 7, 8, 9], vec);
Sourcepub fn retain<F>(&mut self, f: F)
pub fn retain<F>(&mut self, f: F)
Retain only the elements specified by the predicate.
Remove all elements for which the provided function f
returns false from the vector.
Time: O(n)
Sourcepub fn split_at(
self,
index: usize,
) -> (GenericVector<A, P>, GenericVector<A, P>)
pub fn split_at( self, index: usize, ) -> (GenericVector<A, P>, GenericVector<A, P>)
Split a vector at a given index.
Split a vector at a given index, consuming the vector and returning a pair of the left hand side and the right hand side of the split.
Time: O(log n)
§Examples
let mut vec = vector![1, 2, 3, 7, 8, 9];
let (left, right) = vec.split_at(3);
assert_eq!(vector![1, 2, 3], left);
assert_eq!(vector![7, 8, 9], right);
Sourcepub fn split_off(&mut self, index: usize) -> GenericVector<A, P>
pub fn split_off(&mut self, index: usize) -> GenericVector<A, P>
Split a vector at a given index.
Split a vector at a given index, leaving the left hand side in the current vector and returning a new vector containing the right hand side.
Time: O(log n)
§Examples
let mut left = vector![1, 2, 3, 7, 8, 9];
let right = left.split_off(3);
assert_eq!(vector![1, 2, 3], left);
assert_eq!(vector![7, 8, 9], right);
Sourcepub fn skip(&self, count: usize) -> GenericVector<A, P>
pub fn skip(&self, count: usize) -> GenericVector<A, P>
Construct a vector with count
elements removed from the
start of the current vector.
Time: O(log n)
Sourcepub fn take(&self, count: usize) -> GenericVector<A, P>
pub fn take(&self, count: usize) -> GenericVector<A, P>
Construct a vector of the first count
elements from the
current vector.
Time: O(log n)
Sourcepub fn truncate(&mut self, len: usize)
pub fn truncate(&mut self, len: usize)
Truncate a vector to the given size.
Discards all elements in the vector beyond the given length.
Does nothing if len
is greater or equal to the length of the vector.
Time: O(log n)
Sourcepub fn slice<R>(&mut self, range: R) -> GenericVector<A, P>where
R: RangeBounds<usize>,
pub fn slice<R>(&mut self, range: R) -> GenericVector<A, P>where
R: RangeBounds<usize>,
Extract a slice from a vector.
Remove the elements from start_index
until end_index
in
the current vector and return the removed slice as a new
vector.
Time: O(log n)
Sourcepub fn insert(&mut self, index: usize, value: A)
pub fn insert(&mut self, index: usize, value: A)
Insert an element into a vector.
Insert an element at position index
, shifting all elements
after it to the right.
§Performance Note
While push_front
and push_back
are heavily optimised
operations, insert
in the middle of a vector requires a
split, a push, and an append. Thus, if you want to insert
many elements at the same location, instead of insert
ing
them one by one, you should rather create a new vector
containing the elements to insert, split the vector at the
insertion point, and append the left hand, the new vector and
the right hand in order.
Time: O(log n)
Sourcepub fn remove(&mut self, index: usize) -> A
pub fn remove(&mut self, index: usize) -> A
Remove an element from a vector.
Remove the element from position ‘index’, shifting all elements after it to the left, and return the removed element.
§Performance Note
While pop_front
and pop_back
are heavily optimised
operations, remove
in the middle of a vector requires a
split, a pop, and an append. Thus, if you want to remove many
elements from the same location, instead of remove
ing them
one by one, it is much better to use slice
.
Time: O(log n)
Sourcepub fn insert_ord(&mut self, item: A)where
A: Ord,
pub fn insert_ord(&mut self, item: A)where
A: Ord,
Insert an element into a sorted vector.
Insert an element into a vector in sorted order, assuming the vector is already in sorted order.
Time: O(log n)
§Examples
let mut vec = vector![1, 2, 3, 7, 8, 9];
vec.insert_ord(5);
assert_eq!(vector![1, 2, 3, 5, 7, 8, 9], vec);
Sourcepub fn insert_ord_by<F>(&mut self, item: A, f: F)
pub fn insert_ord_by<F>(&mut self, item: A, f: F)
Insert an element into a sorted vector using a comparator function.
Insert an element into a vector in sorted order using the given comparator function, assuming the vector is already in sorted order.
Note that the ordering used to sort the vector must logically match
the ordering in the comparison function provided to insert_ord_by
.
Incompatible definitions of the ordering won’t result in memory
unsafety, but will likely result in out-of-order insertions.
Time: O(log n)
§Examples
let mut vec = vector![9, 8, 7, 3, 2, 1];
vec.insert_ord_by(5, |a, b| a.cmp(b).reverse());
assert_eq!(vector![9, 8, 7, 5, 3, 2, 1], vec);
// Note that `insert_ord` does not work in this case because it uses
// the default comparison function for the item type.
vec.insert_ord(4);
assert_eq!(vector![4, 9, 8, 7, 5, 3, 2, 1], vec);
Sourcepub fn insert_ord_by_key<B, F>(&mut self, item: A, f: F)
pub fn insert_ord_by_key<B, F>(&mut self, item: A, f: F)
Insert an element into a sorted vector where the comparison function delegates to the Ord implementation for values calculated by a user- provided function defined on the item type.
This function assumes the vector is already sorted. If it isn’t sorted, this function may insert the provided value out of order.
Note that the ordering of the sorted vector must logically match the
PartialOrd
implementation of the type returned by the passed comparator
function f
. Incompatible definitions of the ordering won’t result in
memory unsafety, but will likely result in out-of-order insertions.
Time: O(log n)
§Examples
type A = (u8, &'static str);
let mut vec: Vector<A> = vector![(3, "a"), (1, "c"), (0, "d")];
// For the sake of this example, let's say that only the second element
// of the A tuple is important in the context of comparison.
vec.insert_ord_by_key((0, "b"), |a| a.1);
assert_eq!(vector![(3, "a"), (0, "b"), (1, "c"), (0, "d")], vec);
// Note that `insert_ord` does not work in this case because it uses
// the default comparison function for the item type.
vec.insert_ord((0, "e"));
assert_eq!(vector![(3, "a"), (0, "b"), (0, "e"), (1, "c"), (0, "d")], vec);
Trait Implementations§
Source§impl<'a, A, P> Add for &'a GenericVector<A, P>where
A: Clone,
P: SharedPointerKind,
impl<'a, A, P> Add for &'a GenericVector<A, P>where
A: Clone,
P: SharedPointerKind,
Source§fn add(
self,
other: &'a GenericVector<A, P>,
) -> <&'a GenericVector<A, P> as Add>::Output
fn add( self, other: &'a GenericVector<A, P>, ) -> <&'a GenericVector<A, P> as Add>::Output
Concatenate two vectors.
Time: O(log n)
Source§type Output = GenericVector<A, P>
type Output = GenericVector<A, P>
+
operator.Source§impl<A, P> Add for GenericVector<A, P>where
A: Clone,
P: SharedPointerKind,
impl<A, P> Add for GenericVector<A, P>where
A: Clone,
P: SharedPointerKind,
Source§fn add(self, other: GenericVector<A, P>) -> <GenericVector<A, P> as Add>::Output
fn add(self, other: GenericVector<A, P>) -> <GenericVector<A, P> as Add>::Output
Concatenate two vectors.
Time: O(log n)
Source§type Output = GenericVector<A, P>
type Output = GenericVector<A, P>
+
operator.Source§impl<A, P> Clone for GenericVector<A, P>where
A: Clone,
P: SharedPointerKind,
impl<A, P> Clone for GenericVector<A, P>where
A: Clone,
P: SharedPointerKind,
Source§fn clone(&self) -> GenericVector<A, P>
fn clone(&self) -> GenericVector<A, P>
Clone a vector.
Time: O(1), or O(n) with a very small, bounded n for an inline vector.
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<A, P> Debug for GenericVector<A, P>where
A: Debug,
P: SharedPointerKind,
impl<A, P> Debug for GenericVector<A, P>where
A: Debug,
P: SharedPointerKind,
Source§impl<A, P> Default for GenericVector<A, P>where
P: SharedPointerKind,
impl<A, P> Default for GenericVector<A, P>where
P: SharedPointerKind,
Source§fn default() -> GenericVector<A, P>
fn default() -> GenericVector<A, P>
Source§impl<'de, A, P> Deserialize<'de> for GenericVector<A, P>
impl<'de, A, P> Deserialize<'de> for GenericVector<A, P>
Source§fn deserialize<D>(
des: D,
) -> Result<GenericVector<A, P>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
des: D,
) -> Result<GenericVector<A, P>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<A, P> Extend<A> for GenericVector<A, P>where
A: Clone,
P: SharedPointerKind,
impl<A, P> Extend<A> for GenericVector<A, P>where
A: Clone,
P: SharedPointerKind,
Source§fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = A>,
fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = A>,
Add values to the end of a vector by consuming an iterator.
Time: O(n)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Source§impl<'a, A, P> From<&'a [A]> for GenericVector<A, P>where
A: Clone,
P: SharedPointerKind,
impl<'a, A, P> From<&'a [A]> for GenericVector<A, P>where
A: Clone,
P: SharedPointerKind,
Source§fn from(slice: &[A]) -> GenericVector<A, P>
fn from(slice: &[A]) -> GenericVector<A, P>
Source§impl<'s, 'a, A, OA, P1, P2> From<&'s GenericVector<&'a A, P2>> for GenericVector<OA, P1>
impl<'s, 'a, A, OA, P1, P2> From<&'s GenericVector<&'a A, P2>> for GenericVector<OA, P1>
Source§fn from(vec: &GenericVector<&A, P2>) -> GenericVector<OA, P1>
fn from(vec: &GenericVector<&A, P2>) -> GenericVector<OA, P1>
Source§impl<'a, A, S, P1, P2> From<&'a GenericVector<A, P2>> for GenericHashSet<A, S, P1>where
A: Hash + Eq + Clone,
S: BuildHasher + Default + Clone,
P1: SharedPointerKind,
P2: SharedPointerKind,
impl<'a, A, S, P1, P2> From<&'a GenericVector<A, P2>> for GenericHashSet<A, S, P1>where
A: Hash + Eq + Clone,
S: BuildHasher + Default + Clone,
P1: SharedPointerKind,
P2: SharedPointerKind,
Source§fn from(vector: &GenericVector<A, P2>) -> GenericHashSet<A, S, P1>
fn from(vector: &GenericVector<A, P2>) -> GenericHashSet<A, S, P1>
Source§impl<'a, A, P> From<&'a Vec<A>> for GenericVector<A, P>where
A: Clone,
P: SharedPointerKind,
impl<'a, A, P> From<&'a Vec<A>> for GenericVector<A, P>where
A: Clone,
P: SharedPointerKind,
Source§fn from(vec: &Vec<A>) -> GenericVector<A, P>
fn from(vec: &Vec<A>) -> GenericVector<A, P>
Create a vector from a std::vec::Vec
.
Time: O(n)
Source§impl<A, const N: usize, P> From<[A; N]> for GenericVector<A, P>where
P: SharedPointerKind,
A: Clone,
impl<A, const N: usize, P> From<[A; N]> for GenericVector<A, P>where
P: SharedPointerKind,
A: Clone,
Source§fn from(arr: [A; N]) -> GenericVector<A, P>
fn from(arr: [A; N]) -> GenericVector<A, P>
Source§impl<A, S, P1, P2> From<GenericVector<A, P2>> for GenericHashSet<A, S, P1>where
A: Hash + Eq + Clone,
S: BuildHasher + Default + Clone,
P1: SharedPointerKind,
P2: SharedPointerKind,
impl<A, S, P1, P2> From<GenericVector<A, P2>> for GenericHashSet<A, S, P1>where
A: Hash + Eq + Clone,
S: BuildHasher + Default + Clone,
P1: SharedPointerKind,
P2: SharedPointerKind,
Source§fn from(vector: GenericVector<A, P2>) -> GenericHashSet<A, S, P1>
fn from(vector: GenericVector<A, P2>) -> GenericHashSet<A, S, P1>
Source§impl<A, P> From<Vec<A>> for GenericVector<A, P>where
A: Clone,
P: SharedPointerKind,
impl<A, P> From<Vec<A>> for GenericVector<A, P>where
A: Clone,
P: SharedPointerKind,
Source§fn from(vec: Vec<A>) -> GenericVector<A, P>
fn from(vec: Vec<A>) -> GenericVector<A, P>
Create a vector from a std::vec::Vec
.
Time: O(n)
Source§impl<A, P> FromIterator<A> for GenericVector<A, P>where
A: Clone,
P: SharedPointerKind,
impl<A, P> FromIterator<A> for GenericVector<A, P>where
A: Clone,
P: SharedPointerKind,
Source§fn from_iter<I>(iter: I) -> GenericVector<A, P>where
I: IntoIterator<Item = A>,
fn from_iter<I>(iter: I) -> GenericVector<A, P>where
I: IntoIterator<Item = A>,
Create a vector from an iterator.
Time: O(n)
Source§impl<A, P> Hash for GenericVector<A, P>where
A: Hash,
P: SharedPointerKind,
impl<A, P> Hash for GenericVector<A, P>where
A: Hash,
P: SharedPointerKind,
Source§impl<A, P> Index<usize> for GenericVector<A, P>where
P: SharedPointerKind,
impl<A, P> Index<usize> for GenericVector<A, P>where
P: SharedPointerKind,
Source§impl<A, P> IndexMut<usize> for GenericVector<A, P>where
A: Clone,
P: SharedPointerKind,
impl<A, P> IndexMut<usize> for GenericVector<A, P>where
A: Clone,
P: SharedPointerKind,
Source§impl<'a, A, P> IntoIterator for &'a GenericVector<A, P>where
P: SharedPointerKind,
impl<'a, A, P> IntoIterator for &'a GenericVector<A, P>where
P: SharedPointerKind,
Source§impl<'a, A, P> IntoIterator for &'a mut GenericVector<A, P>where
A: Clone,
P: SharedPointerKind,
impl<'a, A, P> IntoIterator for &'a mut GenericVector<A, P>where
A: Clone,
P: SharedPointerKind,
Source§impl<A, P> IntoIterator for GenericVector<A, P>where
A: Clone,
P: SharedPointerKind,
impl<A, P> IntoIterator for GenericVector<A, P>where
A: Clone,
P: SharedPointerKind,
Source§type IntoIter = ConsumingIter<A, P>
type IntoIter = ConsumingIter<A, P>
Source§fn into_iter(self) -> <GenericVector<A, P> as IntoIterator>::IntoIter
fn into_iter(self) -> <GenericVector<A, P> as IntoIterator>::IntoIter
Source§impl<A, P> Ord for GenericVector<A, P>where
A: Ord,
P: SharedPointerKind,
impl<A, P> Ord for GenericVector<A, P>where
A: Ord,
P: SharedPointerKind,
Source§fn cmp(&self, other: &GenericVector<A, P>) -> Ordering
fn cmp(&self, other: &GenericVector<A, P>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<A, P> PartialEq for GenericVector<A, P>where
A: PartialEq,
P: SharedPointerKind,
impl<A, P> PartialEq for GenericVector<A, P>where
A: PartialEq,
P: SharedPointerKind,
Source§impl<A, P> PartialOrd for GenericVector<A, P>where
A: PartialOrd,
P: SharedPointerKind,
impl<A, P> PartialOrd for GenericVector<A, P>where
A: PartialOrd,
P: SharedPointerKind,
Source§impl<A, P> Serialize for GenericVector<A, P>where
A: Serialize,
P: SharedPointerKind,
impl<A, P> Serialize for GenericVector<A, P>where
A: Serialize,
P: SharedPointerKind,
Source§fn serialize<S>(
&self,
ser: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
ser: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Source§impl<A, P> Sum for GenericVector<A, P>where
A: Clone,
P: SharedPointerKind,
impl<A, P> Sum for GenericVector<A, P>where
A: Clone,
P: SharedPointerKind,
Source§fn sum<I>(it: I) -> GenericVector<A, P>where
I: Iterator<Item = GenericVector<A, P>>,
fn sum<I>(it: I) -> GenericVector<A, P>where
I: Iterator<Item = GenericVector<A, P>>,
Self
from the elements by “summing up”
the items.impl<A, P> Eq for GenericVector<A, P>where
A: Eq,
P: SharedPointerKind,
Auto Trait Implementations§
impl<A, P> Freeze for GenericVector<A, P>where
P: Freeze,
impl<A, P> RefUnwindSafe for GenericVector<A, P>where
A: RefUnwindSafe,
P: RefUnwindSafe,
impl<A, P> Send for GenericVector<A, P>
impl<A, P> Sync for GenericVector<A, P>
impl<A, P> Unpin for GenericVector<A, P>where
A: Unpin,
impl<A, P> UnwindSafe for GenericVector<A, P>where
A: UnwindSafe,
P: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more