xtd 0.2.0
xtd::collections::generic::iset< type_t > Class Template Referenceabstract
Inheritance diagram for xtd::collections::generic::iset< type_t >:
xtd::collections::generic::icollection< type_t > xtd::collections::generic::ienumerable< type_t > xtd::collections::generic::extensions::collection_operators< type_t, icollection< type_t > > xtd::interface xtd::collections::generic::extensions::enumerable_iterators< type_t, xtd::collections::generic::ienumerable< type_t > > xtd::collections::generic::extensions::enumerable< ienumerable< type_t >, type_t >

Definition

template<class type_t>
class xtd::collections::generic::iset< type_t >

Provides the base interface for the abstraction of sets.

Definition
template<class type_t>
Defines methods to manipulate generic collections.
Definition icollection.hpp:45
Provides the base interface for the abstraction of sets.
Definition iset.hpp:33
Header
#include <xtd/collections/generic/iset>
Namespace
xtd::collections::generic
Library
xtd.core
Remarks
This interface provides methods for implementing sets, which are collections that have unique elements and specific operations. The xtd::collections::generic::hash_set <type_t> and xtd::collections::generic::sorted_set <type_t> collections implement this interface.

Public Aliases

using iterator = typename icollection< type_t >::iterator
 Represents the iterator of xtd::collections::generic::ienumerable value type.
 
using const_iterator = typename icollection< type_t >::const_iterator
 Represents the const iterator of xtd::collections::generic::ienumerable value type.
 

Public Methods

virtual bool add (const type_t &item) noexcept=0
 Adds an element to the current set and returns a value to indicate if the element was successfully added.
 
virtual void except_with (const xtd::collections::generic::ienumerable< type_t > &other) noexcept=0
 Removes all elements in the specified collection from the current set.
 
virtual void intersec_with (const xtd::collections::generic::ienumerable< type_t > &other) noexcept=0
 Modifies the current set so that it contains only elements that are also in a specified collection.
 
virtual bool is_proper_subset_of (const xtd::collections::generic::ienumerable< type_t > &other) const noexcept=0
 Determines whether the current set is a proper (strict) superset of a specified collection.
 
virtual bool is_proper_superset_of (const xtd::collections::generic::ienumerable< type_t > &other) const noexcept=0
 Determines whether the current set is a proper (strict) superset of a specified collection.
 
virtual bool is_subset_of (const xtd::collections::generic::ienumerable< type_t > &other) const noexcept=0
 Determines whether a set is a subset of a specified collection.
 
virtual bool is_superset_of (const xtd::collections::generic::ienumerable< type_t > &other) const noexcept=0
 Determines whether a set is a superset of a specified collection.
 
virtual bool overlaps (const xtd::collections::generic::ienumerable< type_t > &other) const noexcept=0
 Determines whether the current set overlaps with the specified collection.
 
virtual bool set_equals (const xtd::collections::generic::ienumerable< type_t > &other) const noexcept=0
 Determines whether the current set and the specified collection contain the same elements.
 
virtual void symetric_excep_with (const xtd::collections::generic::ienumerable< type_t > &other) noexcept=0
 Modifies the current set so that it contains only elements that are present either in the current set or in the specified collection, but not both.
 
virtual void union_with (const xtd::collections::generic::ienumerable< type_t > &other) noexcept=0
 Modifies the current set so that it contains all elements that are present in the current set, in the specified collection, or in both.
 

Additional Inherited Members

- Public Types inherited from xtd::collections::generic::icollection< type_t >
using value_type = typename xtd::collections::generic::ienumerable< type_t >::value_type
 Represents the xtd::collections::generic::icollection value type.
 
using iterator = typename xtd::collections::generic::ienumerable< type_t >::iterator
 Represents the iterator of xtd::collections::generic::ienumerable value type.
 
using const_iterator = typename xtd::collections::generic::ienumerable< type_t >::const_iterator
 Represents the const iterator of xtd::collections::generic::ienumerable value type.
 
- Public Types inherited from xtd::collections::generic::ienumerable< type_t >
using value_type = type_t
 Represents the xtd::collections::generic::ienumerable value type.
 
using iterator = typename xtd::collections::generic::extensions::enumerable_iterators< type_t, xtd::collections::generic::ienumerable< type_t > >::iterator
 Represents the iterator of xtd::collections::generic::ienumerable value type.
 
using const_iterator = typename xtd::collections::generic::extensions::enumerable_iterators< type_t, xtd::collections::generic::ienumerable< type_t > >::const_iterator
 Represents the const iterator of xtd::collections::generic::ienumerable value type.
 
- Public Types inherited from xtd::collections::generic::extensions::enumerable_iterators< type_t, xtd::collections::generic::ienumerable< type_t > >
using iterator = enumerable_iterator
 Represents the iterator of enumarable value type.
 
using const_iterator = const enumerable_iterator
 Represents the const iterator of enumarable value type.
 
- Public Types inherited from xtd::collections::generic::extensions::enumerable< ienumerable< type_t >, type_t >
using enumerable_type = ienumerable< type_t >
 Represents the ienumerable enumerable type.
 
using source_type = type_t
 Represents the ienumerable source type.
 
using ienumerable = typename xtd::linq::enumerable::ienumerable< type_t >
 Represents the ienumerable value type.
 
using list = typename xtd::linq::enumerable::list< type_t >
 Represents the list value type.
 
- Public Member Functions inherited from xtd::collections::generic::icollection< type_t >
virtual xtd::size count () const noexcept=0
 Gets the number of elements contained in the xtd::collections::generic::icollection <type_t>.
 
virtual bool is_read_only () const noexcept=0
 Gets a value indicating whether the xtd::collections::generic::icollection <type_t> is read-only.
 
virtual bool is_synchronized () const noexcept=0
 Gets a value indicating whether access to the xtd::collections::generic::icollection <type_t> is synchronized (thread safe).
 
virtual const xtd::objectsync_root () const noexcept=0
 Gets an object that can be used to synchronize access to the the xtd::collections::generic::icollection <type_t>.
 
virtual void clear ()=0
 Removes all items from the xtd::collections::generic::icollection <type_t>.
 
virtual bool contains (const type_t &item) const noexcept=0
 Determines whether the xtd::collections::generic::icollection <type_t> contains a specific value.
 
virtual void copy_to (xtd::array< type_t > &array, xtd::size array_index) const =0
 Copies the elements of the xtd::collections::generic::icollection <type_t> to an xtd::array, starting at a particular xtd::array index.
 
virtual bool remove (const type_t &item)=0
 Removes the first occurrence of a specific object from the xtd::collections::generic::icollection <type_t>.
 
- Public Member Functions inherited from xtd::collections::generic::ienumerable< type_t >
virtual xtd::collections::generic::enumerator< type_t > get_enumerator () const =0
 Returns an enumerator that iterates through a collection.
 
- Public Member Functions inherited from xtd::collections::generic::extensions::enumerable_iterators< type_t, xtd::collections::generic::ienumerable< type_t > >
virtual const_iterator begin () const
 Returns an iterator to the first element of the enumarable.
 
virtual iterator begin ()
 Returns an iterator to the first element of the enumarable.
 
virtual const_iterator cbegin () const
 Returns an iterator to the first element of the enumarable.
 
virtual const_iterator cend () const
 Returns an iterator to the element following the last element of the enumarable.
 
virtual const_iterator end () const
 Returns an iterator to the element following the last element of the enumarable.
 
virtual iterator end ()
 Returns an iterator to the element following the last element of the enumarable.
 
- Public Member Functions inherited from xtd::collections::generic::extensions::enumerable< ienumerable< type_t >, type_t >
type_t aggregate (const std::function< type_t(const type_t &, const type_t &)> &func) const
 Applies an accumulator function over a sequence.
 
type_t aggregate (const type_t &seed, const std::function< type_t(const type_t &, const type_t &)> &func) const
 Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value.
 
accumulate_t aggregate (const accumulate_t &seed, const std::function< accumulate_t(const type_t &, const accumulate_t &)> &func) const
 Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value.
 
type_t aggregate (const type_t &seed, const std::function< type_t(const type_t &, const type_t &)> &func, const std::function< type_t(const type_t &)> &result_selector) const
 Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value, and the specified function is used to select the result value.
 
result_t aggregate (const accumulate_t &seed, const std::function< accumulate_t(const type_t &, const accumulate_t &)> &func, const std::function< result_t(const accumulate_t &)> &result_selector) const
 Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value, and the specified function is used to select the result value.
 
bool all (const std::function< bool(const type_t &)> &predicate) const
 Determines whether all elements of a sequence satisfy a condition.
 
bool any () const noexcept
 Determines whether a sequence contains any elements.
 
bool any (const std::function< bool(const type_t &)> &predicate) const
 Determines whether any element of a sequence satisfies a condition.
 
const ienumerable< type_t > & append (const type_t &element) const noexcept
 Appends a value to the end of the sequence.
 
const ienumerable< type_t > & as_enumerable () const noexcept
 Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
 
auto average () const noexcept
 Computes the average of a sequence of source_t values.
 
const ienumerable< result_t > & cast () const noexcept
 Casts the elements of an xtd::collections::generic::ienumerable to the specified type.
 
const ienumerable< xtd::array< type_t > > & chunk (size_t size) const
 Splits the elements of a sequence into chunks of size at most size.
 
const ienumerable< type_t > & concat (const ienumerable< type_t > &second) const noexcept
 Concatenates two sequences.
 
bool contains (const type_t &value) const noexcept
 Determines whether a sequence contains a specified element by using the default equality comparer.
 
bool contains (const type_t &value, const xtd::collections::generic::iequality_comparer< type_t > &comparer) const noexcept
 Determines whether a sequence contains a specified element by using a specified equality comparer.
 
size_t count () const noexcept
 Returns the number of elements in current sequence.
 
size_t count (const std::function< bool(const type_t &)> &predicate) const noexcept
 Returns a number that represents how many elements in the specified sequence satisfy a condition.
 
const ienumerable< key_value_pair< key_t, xtd::size > > & count_by (const std::function< key_t(const type_t &)> &key_selector) const noexcept
 Returns the count of elements in the current sequence grouped by key.
 
const ienumerable< key_value_pair< key_t, xtd::size > > & count_by (const std::function< key_t(const type_t &)> &key_selector, const iequality_comparer< key_t > &key_comparer) const noexcept
 Returns the count of elements in the current sequence grouped by key.
 
const ienumerable< type_t > & default_if_empty () const noexcept
 Returns the elements of the specified sequence or the type parameter's default value in a singleton collection if the current sequence is empty.
 
const ienumerable< type_t > & default_if_empty (const type_t &default_value) const noexcept
 Returns the elements of the specified sequence or the specified value in a singleton collection if the current sequence is empty.
 
type_t first_or_default (const std::function< bool(const type_t &)> &predicate, const type_t &default_value) const noexcept
 Returns the first element of the sequence that satisfies a condition, or a specified default value if no such element is found.
 
type_t first_or_default (const std::function< bool(const type_t &)> &predicate) const noexcept
 Returns the first element of the sequence that satisfies a condition or a default value if no such element is found.
 
type_t first_or_default (const type_t default_value) const noexcept
 Returns the first element of the sequence that satisfies a condition or a default value if no such element is found.
 
type_t first_or_default () const noexcept
 Returns the first element of the sequence that satisfies a condition or a default value if no such element is found.
 
const ienumerable< result_t > & select (const std::function< result_t(const type_t &)> &selector) const
 Projects each element of a sequence into a new form.
 
const ienumerable< type_t > & select (const std::function< type_t(const type_t &)> &selector) const
 Projects each element of a sequence into a new form.
 
const ienumerable< result_t > & select (const std::function< result_t(const type_t &, size_t index)> &selector) const
 Projects each element of a sequence into a new form by incorporating the element's index.
 
const ienumerable< type_t > & select (const std::function< type_t(const type_t &, size_t index)> &selector) const
 Projects each element of a sequence into a new form by incorporating the element's index.
 
const list< type_t > & to_list () const noexcept
 Creates a xtd::collections::generic::list <type_t> from an xtd::collections::generic::ienumerable <type_t>.
 
const ienumerable< type_t > & where (const std::function< bool(const type_t &)> &predicate) const
 Filters a sequence of values based on a predicate.
 
const ienumerable< type_t > & where (const std::function< bool(const type_t &, size_t)> &predicate) const
 Filters a sequence of values based on a predicate. Each element's index is used in the logic of the predicate function.
 
- Public Member Functions inherited from xtd::collections::generic::extensions::collection_operators< type_t, icollection< type_t > >
virtual icollection< type_t > & operator<< (const type_t &item)
 The shift left operator adds an item to the xtd::collections::generic::icollection <type_t>.
 
virtual icollection< type_t > & operator>> (const type_t &item)
 The shift right operator removes tthe first occurrence of a specific object from the xtd::collections::generic::icollection <type_t>.
 
- Static Public Member Functions inherited from xtd::collections::generic::extensions::enumerable_iterators< type_t, xtd::collections::generic::ienumerable< type_t > >
static target_collection_t::const_iterator to_iterator (typename source_collection_t::const_iterator &value, const source_collection_t &source_collection, const target_collection_t &target_collection) noexcept
 Converts source iterator to target iterator.
 
static target_collection_t::iterator to_iterator (typename source_collection_t::iterator &value, const source_collection_t &source_collection, const target_collection_t &target_collection) noexcept
 Converts source iterator to target iterator.
 
static target_collection_t::const_iterator to_iterator (typename source_collection_t::const_iterator &value, source_collection_t &source_collection, target_collection_t &target_collection) noexcept
 Converts source iterator to target iterator.
 
static target_collection_t::iterator to_iterator (typename source_collection_t::iterator &value, source_collection_t &source_collection, target_collection_t &target_collection) noexcept
 Converts source iterator to target iterator.
 

Member Typedef Documentation

◆ iterator

template<class type_t >
using xtd::collections::generic::iset< type_t >::iterator = typename icollection<type_t>::iterator

Represents the iterator of xtd::collections::generic::ienumerable value type.

◆ const_iterator

template<class type_t >
using xtd::collections::generic::iset< type_t >::const_iterator = typename icollection<type_t>::const_iterator

Represents the const iterator of xtd::collections::generic::ienumerable value type.

Member Function Documentation

◆ add()

template<class type_t >
virtual bool xtd::collections::generic::iset< type_t >::add ( const type_t &  item)
pure virtualnoexcept

Adds an element to the current set and returns a value to indicate if the element was successfully added.

Parameters
itemThe element to add to the set.
Returns
true if the element is added to the set; false if the element is already in the set.

Implements xtd::collections::generic::icollection< type_t >.

◆ except_with()

template<class type_t >
virtual void xtd::collections::generic::iset< type_t >::except_with ( const xtd::collections::generic::ienumerable< type_t > &  other)
pure virtualnoexcept

Removes all elements in the specified collection from the current set.

Parameters
otherThe collection of items to remove from the set.
Remarks
This method is an O(n) operation, where n is the number of elements in the other parameter.

◆ intersec_with()

template<class type_t >
virtual void xtd::collections::generic::iset< type_t >::intersec_with ( const xtd::collections::generic::ienumerable< type_t > &  other)
pure virtualnoexcept

Modifies the current set so that it contains only elements that are also in a specified collection.

Parameters
otherThe collection to compare to the current set.
Remarks
This method ignores any duplicate elements in other.

◆ is_proper_subset_of()

template<class type_t >
virtual bool xtd::collections::generic::iset< type_t >::is_proper_subset_of ( const xtd::collections::generic::ienumerable< type_t > &  other) const
pure virtualnoexcept

Determines whether the current set is a proper (strict) superset of a specified collection.

Parameters
otherThe collection to compare to the current set.
Returns
true if the current set is a proper superset of other; otherwise, false.

◆ is_proper_superset_of()

template<class type_t >
virtual bool xtd::collections::generic::iset< type_t >::is_proper_superset_of ( const xtd::collections::generic::ienumerable< type_t > &  other) const
pure virtualnoexcept

Determines whether the current set is a proper (strict) superset of a specified collection.

Parameters
otherThe collection to compare to the current set.
Returns
true if the current set is a proper superset of other; otherwise, false.

◆ is_subset_of()

template<class type_t >
virtual bool xtd::collections::generic::iset< type_t >::is_subset_of ( const xtd::collections::generic::ienumerable< type_t > &  other) const
pure virtualnoexcept

Determines whether a set is a subset of a specified collection.

Parameters
otherThe collection to compare to the current set.
Returns
true if the current set is a subset of other; otherwise, false.

◆ is_superset_of()

template<class type_t >
virtual bool xtd::collections::generic::iset< type_t >::is_superset_of ( const xtd::collections::generic::ienumerable< type_t > &  other) const
pure virtualnoexcept

Determines whether a set is a superset of a specified collection.

Parameters
otherThe collection to compare to the current set.
Returns
true if the current set is a superset of other; otherwise, false.

◆ overlaps()

template<class type_t >
virtual bool xtd::collections::generic::iset< type_t >::overlaps ( const xtd::collections::generic::ienumerable< type_t > &  other) const
pure virtualnoexcept

Determines whether the current set overlaps with the specified collection.

Parameters
otherThe collection to compare to the current set.
Returns
true if the current set and other share at least one common element; otherwise, false.

◆ set_equals()

template<class type_t >
virtual bool xtd::collections::generic::iset< type_t >::set_equals ( const xtd::collections::generic::ienumerable< type_t > &  other) const
pure virtualnoexcept

Determines whether the current set and the specified collection contain the same elements.

Parameters
otherThe collection to compare to the current set.
Returns
true if the current set is equal to other; otherwise, false.

◆ symetric_excep_with()

template<class type_t >
virtual void xtd::collections::generic::iset< type_t >::symetric_excep_with ( const xtd::collections::generic::ienumerable< type_t > &  other)
pure virtualnoexcept

Modifies the current set so that it contains only elements that are present either in the current set or in the specified collection, but not both.

Parameters
otherThe collection to compare to the current set.
Remarks
Any duplicate elements in other are ignored.

◆ union_with()

template<class type_t >
virtual void xtd::collections::generic::iset< type_t >::union_with ( const xtd::collections::generic::ienumerable< type_t > &  other)
pure virtualnoexcept

Modifies the current set so that it contains all elements that are present in the current set, in the specified collection, or in both.

Parameters
otherThe collection to compare to the current set.
Remarks
Any duplicate elements in other are ignored.

The documentation for this class was generated from the following file: