Unordered
A trait representing an abstract data type for unordered collections of elements.
Type parameters
- T
-
the type of elements contained within this collection (covariant). This trait provides the foundation for implementing unordered data structures by defining fundamental operations such as checking for containment, iterating over elements, and adding new elements. Implementations of this trait must ensure that the order of elements is not relevant or preserved.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
Members list
Value members
Abstract methods
Adds the specified element to the unordered collection.
Adds the specified element to the unordered collection.
Type parameters
- U
-
a supertype of T
Value parameters
- u
-
the element to be added to the collection
Attributes
- Returns
-
a new instance of
Unorderedwith the specified element added
Checks if the specified element is contained within the collection.
Checks if the specified element is contained within the collection.
Value parameters
- u
-
the element to check for existence in the collection
Attributes
- Returns
-
true if the element exists in the collection, otherwise false
Filters the elements of the collection using the provided predicate function.
Filters the elements of the collection using the provided predicate function.
This method returns a new collection that contains only those elements for which the predicate function p evaluates to true.
Value parameters
- p
-
a predicate function that takes an element of type
Tand returns a boolean, indicating whether the element satisfies the condition or not.
Attributes
- Returns
-
an instance of
Unordered[T]containing the elements that satisfy the predicate.
Finds the first element in the collection that satisfies the given predicate function.
Finds the first element in the collection that satisfies the given predicate function.
This method traverses the unordered collection to identify the first element for which the provided predicate function p evaluates to true. If such an element is found, it is returned wrapped in an Option. If no such element exists, None is returned.
Value parameters
- p
-
a predicate function that takes an element of type
Tand returns a boolean, indicating whether the element satisfies the condition.
Attributes
- Returns
-
an
Optioncontaining the first element that satisfies the predicate, orNoneif no such element exists in the collection.
Determines whether the collection is empty.
Determines whether the collection is empty.
This method checks if the unordered collection contains any elements. It returns true if the collection has no elements, and false otherwise.
Attributes
- Returns
-
true if the collection is empty, false otherwise
Returns an iterator over the elements contained in the collection. NOTE that the order of the elements in the iterator is unpredictable.
Returns an iterator over the elements contained in the collection. NOTE that the order of the elements in the iterator is unpredictable.
Attributes
- Returns
-
an iterator that provides sequential access to each element of type
Tin the collection.
Returns the number of elements contained in the unordered collection.
Returns the number of elements contained in the unordered collection.
Attributes
- Returns
-
the total count of elements within the collection as an integer.
Concrete methods
Counts the elements in the collection that satisfy the given predicate.
Counts the elements in the collection that satisfy the given predicate.
This method evaluates each element in the unordered collection using the provided predicate function p. It returns the total number of elements for which the predicate evaluates to true.
Value parameters
- p
-
a predicate function that takes an element of type
Tand returns a boolean, indicating whether the element satisfies the condition
Attributes
- Returns
-
the number of elements in the collection that satisfy the predicate