SortedSet
Implementation of Immutable Sorted Set collection.
You can get it by downloading it directly or by typing:
$ pip install SortedSet
After it is installed you can import it by typing:
>>> from SortedSet.sorted_set import SortedSet
As for the usage it is as simple as:
>>> SortedSet(['list_of_integer_data'])
For example
>>> SortedSet([1, 2, 5, 3, 3, 1])
Would return the following
SortedSet([1, 2, 3, 5])
SortedSet Operations
Union
You can add two SortedSets together either by using '+' operator, calling .union() method on one of the sets and providing the other, or by using union operator '|'.
Take for example these two SortedSets
>>> a = SortedSet([1, 2, 5, 3])
>>> b = SortedSet([2, 4, 6])
We could add them together by running any of these commands
>>> a + b
>>> a.union(b)
>>> a | b
In all three cases the result would be the SortedSet
SortedSet([1, 2, 3, 4, 5, 6])
Difference
You can subtract two SortedSets either calling .difference() method on one of the sets and providing the other, or by using difference operator '-'. Be aware that ordering of SortedSets matters.
Take for example the same two SortedSets we already used
>>> a = SortedSet([1, 2, 5, 3])
>>> b = SortedSet([2, 4, 6])
We can subtract them by running one of these two commands
>>> a - b
>>> a.difference(b)
In both cases the result would be the SortedSet
SortedSet([1, 3, 5])
If we were to switch the order of the operands
>>> b - a
>>> b.difference(a)
We would get entirely different result
SortedSet([4, 6])
Symmetric Difference
You can find unique members that are only contained in one of the two SortedSets either by calling .symmetric_difference() method on one of the sets and providing the other, or by using symmetric difference operator '^'.
>>> a = SortedSet([1, 2, 5, 3])
>>> b = SortedSet([2, 4, 6])
>>> a.symmetric_difference(b)
SortedSet([1, 3, 4, 5, 6])
>>> b ^ a
SortedSet([1, 3, 4, 5, 6])
Intersection
You can find unique members that are contained in both of the two SortedSets either by calling .intersection() method on one of the sets and providing the other, or by using intersection operator '&'.
>>> a = SortedSet([1, 2, 5, 3])
>>> b = SortedSet([2, 4, 6])
>>> a.intersection(b)
SortedSet([2])
>>> b & a
SortedSet([2])
Superset, Subset and Disjoint
It is also possible to check if one SortedSet is a superset or subset of another either by using .issuperset() and .issubset() methods or by using operators '>=' and '<='.
>>> a = SortedSet([1, 2])
>>> b = SortedSet([1, 2, 3])
>>> a.issuperset(b)
False
>>> a >= b
False
>>> a.issubset(b)
True
>>> a <= b
True
You can find out are two SortedSets disjoint, meaning that they have no common members by running .isdisjoint() method on one of the SortedSets.
>>> a = SortedSet([1, 3])
>>> b = SortedSet([6, 4, 8])
>>> a.isdisjoint(b)
True
>>> a = SortedSet([4, 3])
>>> b = SortedSet([6, 4, 8])
>>> b.isdisjoint(a)
False
Other operations
Other supported operations are:
len() contains() comparison of two SortedSets for equality or inequality access to SortedSet members by their index
>>> a = SortedSet([1, 3, 7, 5])
>>> len(a)
4
/>>> a.contains(1)
True
>>> a.contains(31)
False
>>> b = SortedSet([2, 3])
>>> a == b
False
>>> c = SortedSet([3, 1, 5, 7])
>>> a == c
True
>>> a != b
True
>>> a[0]
1
>>> b[1]
3
Metadata
Release files for SortedSet 1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| SortedSet-1.0.tar.gz | 3.3 kB | Without provenance | Details |
Release files / SortedSet-1.0.tar.gz
| Download URL | SortedSet-1.0.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0187d280ea066875670df569101a302f19aa0861a3afc7e038e79a6ed66cb605
|
|
BLAKE2b-256 checksum How to use checksums |
a29c31506d0001d15f067818343d4f5029b1bfce15d678607e3d52afa414abe3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for SortedSet 1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.