ListSet<T> class
A ListSet is, at the same time:
When viewed as a Set and compared to a LinkedHashSet, a ListSet is also ordered and has a similar performance. But a ListSet takes less memory and can be sorted, just like a list. Also, you can directly get its items by index. The disadvantage, of course, is that ListSet has a fixed size, while a LinkedHashSet does not.
The ListSet is efficient both as a List and as a Set. So, for example, it has an efficient sort method, while a LinkedHashSet would force you to turn it into a List, then sort it, than turn it back into a Set.
- Implemented types
- Implementers
- Available extensions
Constructors
- ListSet.empty()
- ListSet.fromJson(dynamic json, T fromJsonT(Object?))
-
Converts from JSon. Json serialization support for json_serializable with @JsonSerializable.
factory
-
ListSet.of(Iterable<
T> items, {bool sort = false, int compare(T a, T b)?}) -
Create a ListSet from the
items
iterable.
Properties
-
asComparableEntries
→ Iterable<
Entry< K, V> > -
Available on Iterable<
MapEntry is not Comparable. If you need to compare two iterables of MapEntry you can do this:MapEntry< , provided by the FicIterableOfMapEntryExtension extensionK, V> >no setter - first ↔ T
-
The first element.
getter/setter pairoverride
- firstOrNull → T?
-
Available on Iterable<
The first element of this iterator, orT> , provided by the IterableExtensions extensionnull
if the iterable is empty.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
-
indexed
→ Iterable<
(int, T)> -
Available on Iterable<
Pairs of elements of the indices and elements of this iterable.T> , provided by the IterableExtensions extensionno setter - isEmpty → bool
-
Whether this collection has no elements.
no setteroverride
- isNotEmpty → bool
-
Whether this collection has at least one element.
no setteroverride
-
iterator
→ Iterator<
T> -
An iterator that iterates over the elements of this set.
no setteroverride
- last ↔ T
-
The last element.
getter/setter pairoverride
- lastOrNull → T?
-
Available on Iterable<
The last element of this iterable, orT> , provided by the IterableExtensions extensionnull
if the iterable is empty.no setter - length ↔ int
-
The number of elements in this Iterable.
getter/setter pairoverride
-
lock
→ IList<
T> -
Available on List<
Locks the list, returning an immutable list (IList).T> , provided by the FicListExtension extensionno setter -
lock
→ ISet<
T> -
Available on Set<
Locks the set, returning an immutable set (ISet).T> , provided by the FicSetExtension extensionno setter -
lockUnsafe
→ IList<
T> -
Available on List<
Locks the list, returning an immutable list (IList).T> , provided by the FicListExtension extensionno setter -
lockUnsafe
→ ISet<
T> -
Available on Set<
Locks the set, returning an immutable set (ISet).T> , provided by the FicSetExtension extensionno setter -
nonNulls
→ Iterable<
T> -
Available on Iterable<
The non-T?> , provided by the NullableIterableExtensions extensionnull
elements of this iterable.no setter -
reversed
→ Iterable<
T> -
An Iterable of the objects in this list in reverse order.
no setteroverride
-
reversedView
→ ListSet<
T> -
no setter
-
reversedView
→ List<
T> -
Available on List<
Returns a List of the objects in this list in reverse order. Very efficient since it returns a view (which means, if you change the original list this one will also change, and vice-versa).T> , provided by the FicListExtension extensionno setter - 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 setteroverride
- singleOrNull → T?
-
Available on Iterable<
The single element of this iterator, orT> , provided by the IterableExtensions extensionnull
.no setter -
toJS
→ JSArray<
T> -
Available on List<
Converts this List to a JSArray by either casting, unwrapping, or cloning the List.T> , provided by the ListToJSArray extensionno setter -
toJSProxyOrRef
→ JSArray<
T> -
Available on List<
Converts this List to a JSArray by either casting, unwrapping, or proxying the List.T> , provided by the ListToJSArray extensionno setter -
wait
→ Future<
List< T> > -
Available on Iterable<
Waits for futures in parallel.Future< , provided by the FutureIterable extensionT> >no setter
Methods
-
add(
T value) → bool -
Adds
value
to the set.override -
addAll(
Iterable< T> elements) → void -
Adds all
elements
to this set.override -
addBetween(
T separator) → List< T> -
Available on List<
Return a new list, adding a separator between the original list items (but not before the first and after the last).T> , provided by the FicListExtension extension -
any(
Predicate< T> test) → bool -
Checks whether any element of this iterable satisfies
test
.override -
anyIs(
T value) → bool -
Available on Iterable<
ReturnsT> , provided by the FicIterableExtension extensiontrue
if any item is equal tovalue
. -
asList(
) → List< T> -
Available on Iterable<
Returns a List containing the elements of this iterable. If the Iterable is already a List, return the same instance (nothing new is created). Otherwise, create a new List from it. See also: Dart's native toList, which always creates a new list.T> , provided by the FicIterableExtension extension -
asMap(
) → Map< int, T> -
An unmodifiable Map view of this list.
override
-
asNameMap(
) → Map< String, T> -
Available on Iterable<
Creates a map from the names of enum values to the values.T> , provided by the EnumByName extension -
asSet(
) → Set< T> -
Available on Iterable<
Creates a Set containing the same elements as this iterable. If the Iterable is already a Set, return the same instance (nothing new is created). Otherwise, create a new Set from it. See also: Dart's native toSet, which always creates a new set.T> , provided by the FicIterableExtension extension -
averageBy<
N extends num> (N mapper(T element)) → double -
Available on Iterable<
The arithmetic mean of the elements of a non-empty iterable. The arithmetic mean is the sum of the elements divided by the number of elements. If iterable is empty it returns 0. Examples:T> , provided by the FicIterableExtension extension -
byName(
String name) → T -
Available on Iterable<
Finds the enum value in this list with nameT> , provided by the EnumByName extensionname
. -
cast<
E> () → ListSet< E> -
Provides a view of this set as a set of
R
instances.override -
clear(
) → void -
Removes all elements from the set.
override
-
compareAsSets(
List other) → bool -
Available on List<
ReturnT> , provided by the FicListExtension extensiontrue
if the lists contain the same items (in any order). Ignores repeated items. -
concat(
List< T> ? list2, [List<T> ? list3, List<T> ? list4, List<T> ? list5]) → List<T> -
Available on List<
Return an efficient concatenation of up to 5 lists:T> , provided by the FicListExtension extension -
contains(
covariant T? value) → bool -
Whether
value
is in the set.override -
containsAll(
covariant Iterable< T?> other) → bool -
Whether this set contains all the elements of
other
.override -
deepEquals(
Iterable? other, {bool ignoreOrder = false}) → bool -
Available on Iterable<
Compare all items, in order or not, according toT> , provided by the FicIterableExtension extensionignoreOrder
, using operator ==. Return true if they are all the same, in the same order. -
deepEqualsByIdentity(
Iterable? other, {bool ignoreOrder = false}) → bool -
Available on Iterable<
Return true if they are all the same, in the same order. Compare all items, in order or not, according toT> , provided by the FicIterableExtension extensionignoreOrder
, using identical. Return true if they are all the same, in the same order. -
diffAndIntersect<
G> (Set< G> other, {bool diffThisMinusOther = true, bool diffOtherMinusThis = true, bool intersectThisWithOther = true, bool intersectOtherWithThis = true}) → DiffAndIntersectResult<T, G> -
Available on Set<
Given this set andT> , provided by the FicSetExtension extensionother
, returns: -
difference(
covariant Set< T?> other) → Set<T> -
Creates a new set with the elements of this that are not in
other
.override -
distinct(
{dynamic by(T item)?}) → List< T> -
Available on List<
Returns a new list, which is equal to the original one, but without duplicates. In other words, the new list has only distinct items. Optionally, you can provide anT> , provided by the FicListExtension extensionid
function to compare the items. -
divideList(
Predicate< T> test) → List<List< T> > -
Available on List<
Search a list for items that satisfy aT> , provided by the FicListExtension extensiontest
predicate (matching items), and then divide that list into parts, such as each part contains one matching item. Except maybe for the first matching item, it will keep the matching items as the first item in each part. -
divideListAsMap<
G> (bool test(T item), {G key(T item)?, bool includeFirstItems = false}) → Map< G, List< T> > -
Available on List<
Search a list for items that satisfy aT> , provided by the FicListExtension extensiontest
predicate (matching items), and then divide that list into a Map of parts, such as each part contains one matching item, and the keys are given by thekey
function. -
elementAt(
int index) → T -
Returns the
index
th element.override -
elementAtOrNull(
int index) → T? -
Available on Iterable<
The element at positionT> , provided by the IterableExtensions extensionindex
of this iterable, ornull
. -
every(
Predicate< T> test) → bool -
Checks whether every element of this iterable satisfies
test
.override -
everyIs(
T value) → bool -
Available on Iterable<
ReturnsT> , provided by the FicIterableExtension extensiontrue
if all items are equal tovalue
. -
expand<
E> (Iterable< E> f(T element)) → Iterable<E> -
Expands each element of this Iterable into zero or more elements.
override
-
fillRange(
int start, int end, [T? fillValue]) → void -
Overwrites a range of elements with
fillValue
.override -
findDuplicates(
) → Set< T> -
Available on Iterable<
Finds duplicates and then returns a Set with the duplicated elements. If there are no duplicates, an empty Set is returned.T> , provided by the FicIterableExtension extension -
firstWhere(
Predicate< T> test, {T orElse()?}) → T -
The first element that satisfies the given predicate
test
.override -
fold<
E> (E initialValue, E combine(E previousValue, T element)) → E -
Reduces a collection to a single value by iteratively combining each
element of the collection with an existing value
override
-
followedBy(
Iterable< T> other) → Iterable<T> -
Creates the lazy concatenation of this iterable and
other
.override -
forEach(
void f(T element)) → void -
Invokes
action
on each element of this iterable in iteration order.override -
get(
int index, {T orElse(int index)?}) → T -
Available on List<
Returns theT> , provided by the FicListExtension extensionindex
th element. If that index doesn't exist (negative, or out of range), will return the result of callingorElse
. In this case, iforElse
is not provided, will throw an error. -
getAndMap(
int index, T map(int index, bool inRange, T? value)) → T -
Available on List<
Gets theT> , provided by the FicListExtension extensionindex
th element, and then apply themap
function to it, returning the result. If that index doesn't exist (negative, or out of range), will themap
method will be called withinRange
false andvalue
null. -
getOrNull(
int index) → T? -
Available on List<
Returns theT> , provided by the FicListExtension extensionindex
th element. If that index doesn't exist (negative or out of range), will return null. This method will never throw an error. -
getRange(
int start, int end) → Iterable< T> -
Creates an Iterable that iterates over a range of elements.
override
-
indexOf(
T element, [int start = 0]) → int -
The first index of
element
in this list.override -
indexWhere(
Predicate< T> test, [int start = 0]) → int -
The first index in the list that satisfies the provided
test
.override -
insert(
int index, T element) → void -
Inserts
element
at positionindex
in this list.override -
insertAll(
int index, Iterable< T> iterable) → void -
Inserts all objects of
iterable
at positionindex
in this list.override -
intersection(
covariant Set< T?> other) → Set<T> -
Creates a new set which is the intersection between this set and
other
.override -
intersectsWith(
Iterable< T> other) → bool -
Available on Iterable<
Returns true if this Iterable has any items in common with theT> , provided by the FicIterableExtension extensionother
Iterable. This method is as performant as possible, but it will be faster if any of the Iterables is a Set or an ISet. -
isFirst(
T item) → bool -
Available on Iterable<
Return true if the givenT> , provided by the FicIterableExtension extensionitem
is the same (by identity) as the first iterable item. If this iterable is empty, always return null. This is useful for non-indexed loops where you need to know when you have the first item. For example: -
isLast(
T item) → bool -
Available on Iterable<
Return true if the givenT> , provided by the FicIterableExtension extensionitem
is the same (by identity) as the last iterable item. If this iterable is empty, always return null. This is useful for non-indexed loops where you need to know when you have the last item. For example: -
isNotFirst(
T item) → bool -
Available on Iterable<
Return true if the givenT> , provided by the FicIterableExtension extensionitem
is NOT the same (by identity) as the first iterable item. If this iterable is empty, always return null. This is useful for non-indexed loops where you need to know when you don't have the first item. For example: -
isNotLast(
T item) → bool -
Available on Iterable<
Return true if the givenT> , provided by the FicIterableExtension extensionitem
is NOT the same (by identity) as the last iterable item. If this iterable is empty, always return null. This is useful for non-indexed loops where you need to know when you don't have the last item. For example: -
join(
[String separator = ""]) → String -
Converts each element to a String and concatenates the strings.
override
-
lastIndexOf(
T element, [int? start]) → int -
The last index of
element
in this list.override -
lastIndexWhere(
Predicate< T> test, [int? start]) → int -
The last index in the list that satisfies the provided
test
.override -
lastWhere(
Predicate< T> test, {T orElse()?}) → T -
The last element that satisfies the given predicate
test
.override -
lookup(
Object? object) → T? -
If an object equal to
object
is in the set, return it.override -
map<
E> (E f(T e)) → Iterable< E> -
The current elements of this iterable modified by
toElement
.override -
mapIndexedAndLast<
R> (R convert(int index, T item, bool isLast)) → Iterable< R> -
Available on Iterable<
Maps each element and its index to a new value. This is similar toT> , provided by the FicIterableExtension extensionmapIndexed
but also tells you which item is the last. -
mapNotNull<
E> (E? f(T? e)) → Iterable< E> -
Available on Iterable<
Similar to map, but MAY return a non-nullable type.T?> , provided by the FicIterableExtensionTypeNullable extension -
moveToTheEnd(
T item) → void -
Available on List<
Moves the first occurrence of theT> , provided by the FicListExtension extensionitem
to the end of the list. -
moveToTheFront(
T item) → void -
Available on List<
Moves the first occurrence of theT> , provided by the FicListExtension extensionitem
to the start of the list. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
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.
override
-
remove(
Object? value) → bool -
Removes
value
from the set.override -
removeAll(
Iterable< Object?> elements) → void -
Removes each element of
elements
from this set.override -
removeAt(
int index) → T -
Removes the object at position
index
from this list.override -
removeDuplicates(
{dynamic by(T item)?, bool removeNulls = false}) → void -
Available on List<
Removes all duplicates from the list, leaving only the distinct items. Optionally, you can provide anT> , provided by the FicListExtension extensionid
function to compare the items. -
removeLast(
) → T -
Removes and returns the last object in this list.
override
-
removeNulls(
) → void -
Available on List<
Removes allT> , provided by the FicListExtension extensionnull
s from the List. -
removeNulls(
) → void -
Available on Set<
Removes allT> , provided by the FicSetExtension extensionnull
s from the Set. -
removeRange(
int start, int end) → void -
Removes a range of elements from the list.
override
-
removeWhere(
Predicate< T> test) → void -
Removes all elements of this set that satisfy
test
.override -
replaceRange(
int start, int end, Iterable< T> replacement) → void -
Replaces a range of elements with the elements of
replacements
.override -
restrict(
T? item, {required T orElse}) → T -
Available on Iterable<
Restricts some item to one of those present in this iterable.T> , provided by the FicIterableExtension extension -
retainAll(
Iterable< Object?> elements) → void -
Removes all elements of this set that are not elements in
elements
.override -
retainWhere(
Predicate< T> test) → void -
Removes all elements of this set that fail to satisfy
test
.override -
setAll(
int index, Iterable< T> iterable) → void -
Overwrites elements with the objects of
iterable
.override -
setRange(
int start, int end, Iterable< T> iterable, [int skipCount = 0]) → void -
Writes some elements of
iterable
into a range of this list.override -
shuffle(
[Random? random]) → void -
Shuffles the elements of this list randomly.
override
-
singleWhere(
Predicate< T> test, {T orElse()?}) → T -
The single element that satisfies
test
.override -
skip(
int count) → Iterable< T> -
Creates an Iterable that provides all but the first
count
elements.override -
skipWhile(
bool test(T value)) → Iterable< T> -
Creates an
Iterable
that skips leading elements whiletest
is satisfied.override -
sort(
[int compare(T a, T b)?]) → void -
Sorts this list according to the order specified by the
compare
function.override -
sortedLike(
Iterable ordering) → List< T> -
Available on Iterable<
Returns a list, sorted according to the order specified by theT> , provided by the FicIterableExtension extensionordering
iterable. Items which don't appear inordering
will be included in the end, in their original order. Items ofordering
which are not found in the original list are ignored. -
sortedReversed(
[Comparator< T> ? compare]) → List<T> -
Available on Iterable<
Creates a reversed sorted list of the elements of the iterable.T> , provided by the FicIterableExtension extension -
sortLike(
Iterable ordering) → void -
Available on List<
Sorts this list according to the order specified by theT> , provided by the FicListExtension extensionordering
iterable. Items which don't appear inordering
will be included in the end, in their original order. Items ofordering
which are not found in the original list are ignored. -
sortOrdered(
[int compare(T a, T b)?]) → void -
Available on List<
Sorts this list according to the order specified by theT> , provided by the FicListExtension extensioncompare
function. -
sortReversed(
[int compare(T a, T b)?]) → void -
Available on List<
Sorts this list in reverse order in relation to the default sort method.T> , provided by the FicListExtension extension -
splitByLength(
int length) → List< List< T> > -
Available on List<
Cut the original list into one or more lists with at mostT> , provided by the FicListExtension extensionlength
items. -
splitList(
bool test(T item), {bool emptyParts = false}) → Iterable< List< T> > -
Available on List<
Split a list, according to a predicate, removing the list item that satisfies the predicate.T> , provided by the FicListExtension extension -
sublist(
int start, [int? end]) → List< T> -
Returns a new list containing the elements between
start
andend
.override -
sumBy<
N extends num> (N mapper(T element)) → N -
Available on Iterable<
The sum of the values returned by theT> , provided by the FicIterableExtension extensionmapper
function. -
take(
int count) → Iterable< T> -
Creates a lazy iterable of the
count
first elements of this iterable.override -
takeWhile(
bool test(T value)) → Iterable< T> -
Creates a lazy iterable of the leading elements satisfying
test
.override -
toggle(
T item) → bool -
Available on List<
If the item does not exist in the list, add it and returnT> , provided by the FicListExtension extensiontrue
. If it already exists, remove the first instance of it and returnfalse
. -
toggle(
T item) → bool -
Available on Set<
If the item doesn't exist in the set, add it and returnT> , provided by the FicSetExtension extensiontrue
. Otherwise, if the item already exists in the set, remove it and returnfalse
. -
toIList(
[ConfigList? config]) → IList< T> -
Available on Iterable<
Creates an immutable list (IList) from the iterable.T> , provided by the FicIterableExtension extension -
toISet(
[ConfigSet? config]) → ISet< T> -
Available on Iterable<
Creates an immutable set (ISet) from the iterable.T> , provided by the FicIterableExtension extension -
toJson(
Object? toJsonT(T)) → Object - Converts to JSon. Json serialization support for json_serializable with @JsonSerializable.
-
toList(
{bool growable = true}) → List< T> -
Creates a List containing the elements of this Iterable.
override
-
toSet(
) → Set< T> -
Creates a Set with the same elements and behavior as this
Set
.override -
toString(
) → String -
A string representation of this object.
inherited
-
union(
covariant Set< T> other) → Set<T> -
Creates a new set which contains all the elements of this set and
other
.override -
unzip(
) → (Iterable< U> , Iterable<V> ) -
Available on Iterable<
Iterable Record as Iterable(U, V)> , provided by the FICZipExtension extension -
updateById(
Iterable< T> newItems, dynamic id(T item)) → List<T> -
Available on Iterable<
Returns a new list whereT> , provided by the FicIterableExtension extensionnewItems
are added or updated, by theirid
(and theid
is a function of the item), like so: -
where(
Predicate< T> test) → Iterable<T> -
Creates a new lazy Iterable with all elements that satisfy the
predicate
test
.override -
whereMoveToTheEnd(
bool test(T item)) → void -
Available on List<
Moves all items that satisfy the providedT> , provided by the FicListExtension extensiontest
to the end of the list. Keeps the relative order of the moved items. -
whereMoveToTheFront(
bool test(T item)) → void -
Available on List<
Moves all items that satisfy the providedT> , provided by the FicListExtension extensiontest
to the start of the list. Keeps the relative order of the moved items. -
whereNoDuplicates(
{dynamic by(T item)?, bool removeNulls = false}) → Iterable< T> -
Available on Iterable<
Removes all duplicates, leaving only the distinct items. Optionally, you can provide anT> , provided by the FicIterableExtension extensionby
function to compare the items. -
whereType<
E> () → Iterable< E> -
Creates a new lazy Iterable with all elements that have type
T
.override -
withNullsRemoved(
) → List< T> -
Available on List<
Returns a new List with allT?> , provided by the FicListExtensionNullable extensionnull
s removed. This may return a list with a non-nullable type.
Operators
-
operator +(
List< T> other) → ListSet<T> -
Returns the concatenation of this list and
other
.override -
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator [](
int index) → T -
The object at the given
index
in the list.override -
operator []=(
int index, T value) → void -
Sets the value at the given
index
in the list tovalue
.override
Static Methods
-
unsafeView<
T> (Set< T> set) → ListSet<T> -
Creates a ListSet form the given
set
. If theset
is already of type ListSet, return the same instance. This is unsafe because a ListSetView is fixed size, but the givenset
may not.