Vector<T extends Comparable> class
A C++ style Vector collection backed by a Dart List.
- Mixed-in types
Constructors
Properties
- first → T
-
The first element.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setteroverride
- isEmpty → bool
-
Whether this collection has no elements.
no setterinherited
- isNotEmpty → bool
-
Whether this collection has at least one element.
no setterinherited
-
iterator
→ Iterator<
T> -
Exposes the iterator from the underlying list.
This allows the Vector to be used in standard Dart
for (var x in vec)loops.no setteroverride - last → T
-
The last element.
no setterinherited
- length → int
-
Returns the number of elements in the vector (O(1) time).
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- single → T
-
Checks that this iterable has only one element, and returns that element.
no setterinherited
Methods
-
any(
bool test(T element)) → bool -
Checks whether any element of this iterable satisfies
test.inherited -
assign(
int count, T value) → void -
Replaces the contents of the vector with
countcopies ofvalue. -
at(
int index) → T -
Retrieves the element at the specified
index. -
back(
) → T - Retrieves the last element of the vector.
-
cast<
R> () → Iterable< R> -
A view of this iterable as an iterable of
Rinstances.inherited -
clear(
) → void - Removes all elements from the vector.
-
compareTo(
Vector< T> other) → int -
Lexicographically compares this vector to
other. -
contains(
Object? element) → bool -
Whether the collection contains an element equal to
element.override -
elementAt(
int index) → T -
Returns the
indexth element.inherited -
empty(
) → bool - Returns true if the vector contains no elements.
-
every(
bool test(T element)) → bool -
Checks whether every element of this iterable satisfies
test.inherited -
expand<
T> (Iterable< T> toElements(T element)) → Iterable<T> -
Expands each element of this Iterable into zero or more elements.
inherited
-
firstWhere(
bool test(T element), {T orElse()?}) → T -
The first element that satisfies the given predicate
test.inherited -
fold<
T> (T initialValue, T combine(T previousValue, T element)) → T -
Reduces a collection to a single value by iteratively combining each
element of the collection with an existing value
inherited
-
followedBy(
Iterable< T> other) → Iterable<T> -
Creates the lazy concatenation of this iterable and
other.inherited -
forEach(
void action(T element)) → void -
Invokes
actionon each element of this iterable in iteration order.inherited -
front(
) → T - Retrieves the first element of the vector.
-
indexOf(
T element) → int -
Returns the first index of
elementin the vector. -
insert(
int index, T value) → void -
Inserts
valueat the specifiedindex. -
insertAll(
int index, Iterable< T> iterable) → void -
Inserts a range of elements from
iterablestarting atindex. -
join(
[String separator = ""]) → String -
Converts each element to a String and concatenates the strings.
inherited
-
lastWhere(
bool test(T element), {T orElse()?}) → T -
The last element that satisfies the given predicate
test.inherited -
map<
T> (T toElement(T e)) → Iterable< T> -
The current elements of this iterable modified by
toElement.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
popBack(
) → void - Removes the last element from the vector.
-
pushBack(
T value) → void - Adds an element to the end of the vector.
-
reduce(
T combine(T value, T element)) → T -
Reduces a collection to a single value by iteratively combining elements
of the collection using the provided function.
inherited
-
remove(
T element) → void -
Removes the first occurrence of
elementfrom the vector. -
removeAt(
int index) → void -
Removes the element at the specified
index. -
removeLast(
) → void - Removes the last element of the vector.
-
removeRange(
int start, int end) → void -
Removes a range of elements from
starttoend. -
removeWhere(
bool test(T element)) → void -
Removes all elements that satisfy the given
test. -
resize(
int count, T fill) → void -
Resizes the vector to contain
countelements. If the current size is greater thancount, the container is reduced to its firstcountelements. If the current size is less thancount, the container is expanded by inserting copies offill. -
retainWhere(
bool test(T element)) → void -
Retains only the elements that satisfy the given
test. -
reverse(
) → void - Reverses the elements of the vector in place.
-
shuffle(
) → void - Shuffles the elements of the vector randomly.
-
singleWhere(
bool test(T element), {T orElse()?}) → T -
The single element that satisfies
test.inherited -
size(
) → int - Returns the number of elements in the vector.
-
skip(
int count) → Iterable< T> -
Creates an Iterable that provides all but the first
countelements.inherited -
skipWhile(
bool test(T value)) → Iterable< T> -
Creates an
Iterablethat skips leading elements whiletestis satisfied.inherited -
sort(
) → void - Sorts the elements of the vector.
-
swap(
Vector< T> other) → void -
Exchanges the contents of this vector with those of
other. -
take(
int count) → Iterable< T> -
Creates a lazy iterable of the
countfirst elements of this iterable.inherited -
takeWhile(
bool test(T value)) → Iterable< T> -
Creates a lazy iterable of the leading elements satisfying
test.inherited -
toList(
{bool growable = true}) → List< T> -
Creates a List containing the elements of this Iterable.
inherited
-
toSet(
) → Set< T> -
Creates a Set containing the same elements as this iterable.
inherited
-
toString(
) → String -
A string representation of this object.
override
-
where(
bool test(T element)) → Iterable< T> -
Creates a new lazy Iterable with all elements that satisfy the
predicate
test.inherited -
whereType<
T> () → Iterable< T> -
Creates a new lazy Iterable with all elements that have type
T.inherited
Operators
-
operator *(
int times) → Vector< T> -
You can overload the multiplication operator to take an int and return a new Vector repeated n times
(similar to Python's
1, 2* 3 ==1, 2, 1, 2, 1, 2). -
operator +(
Vector< T> other) → Vector<T> - Concatenates two vectors. Guarantees memory safety by creating a new vector with the combined elements.
-
operator -(
Vector< T> other) → Vector<T> -
Removes all occurrences of elements found in
other -
operator <(
Vector< T> other) → bool - Less-than comparison for vectors.
-
operator <=(
Vector< T> other) → bool - Less-than-or-equal comparison for vectors.
-
operator ==(
Object other) → bool -
The equality operator.
override
-
operator >(
Vector< T> other) → bool - Greater-than comparison for vectors.
-
operator >=(
Vector< T> other) → bool - Greater-than-or-equal comparison for vectors.
-
operator [](
int index) → T -
Retrieves the element at the specified
index. -
operator []=(
int index, T value) → void -
Sets the element at the specified
indextovalue. -
operator ~(
) → List< T> - Converts the vector to a standard Dart list.