sinter
SINTER
Get the intersection
Usage is sinter key1 key2.
myset1 = { A, B, C }
myset2 = { B, C, D }
SINTER myset1 myset2 = { B, C }
Example
| Command> | sadd myset1 A B C |
| Result> | 3 |
| Command> | sadd myset2 B C D |
| Result> | 3 |
| Command> | sinter myset1 myset2
|
| Result> |
1) B
2) C
|
View animation
Intersection of three sets
Usage is sinter key1 key2 key3.
myset1 = { A, B, C }
myset2 = { B, C, D }
myset3 = { C, E, F }
SINTER myset1 myset2 myset3 = { C }
There is no limit on the number of keys.
Example
| Command> | sadd myset3 C E F |
| Result> | 3 |
| Command> | sinter myset1 myset2 myset3
|
| Result> |
1) C
|
Sort feature
sort or asc sorts in ascending order;
desc sorts in descending order.
Example
| Command> | sinter myset1 myset2 sort
|
| Result> |
1) B
2) C
|
| Command> | sinter myset1 myset2 desc
|
| Result> |
1) C
2) B |
Syntax
SINTER key [key ...] [sort|asc|desc]
- Available since version 1.0.0.
- Time complexity is O(N*M). N is the number of members in the smallest set,
and M is the number of sets.