@@ -207,9 +207,9 @@ of one set is also a member of the other set; otherwise, returns `false`.
207207``` erlang
2082081 > Empty = gb_sets :new ().
2092092 > S = gb_sets :from_list ([a ,b ]).
210- 3 > gb_sets :is_equal (S , S )
210+ 3 > gb_sets :is_equal (S , S ).
211211true
212- 4 > gb_sets :is_equal (S , Empty )
212+ 4 > gb_sets :is_equal (S , Empty ).
213213false
214214```
215215""" .
@@ -380,7 +380,7 @@ does not rebalance the tree.
380380## Examples
381381
382382``` erlang
383- 1 > S0 = gb_sets :from_ordset (lists :seq (1 , 100 )).
383+ 1 > S0 = gb_sets :from_list (lists :seq (1 , 100 )).
3843842 > Delete = fun (E , Set ) -> gb_sets :delete (E , Set ) end .
3853853 > S1 = lists :foldl (Delete , S0 , lists :seq (1 , 50 )).
3863864 > gb_sets :size (S1 ).
@@ -460,7 +460,7 @@ contain duplicates.
460460## Examples
461461
462462``` erlang
463- 1 > Unordered = [x ,y ,a ,x ,y ,b ,b ,z ]
463+ 1 > Unordered = [x ,y ,a ,x ,y ,b ,b ,z ].
4644642 > gb_sets :to_list (gb_sets :from_list (Unordered )).
465465[a ,b ,x ,y ,z ]
466466```
@@ -797,10 +797,10 @@ The implementation is very efficient; traversing the whole set using
797797[ ` next/1 ` ] ( `next/1` ) is only slightly slower than getting the list of
798798all elements using ` to_list/1 ` and traversing that. The main advantage
799799of the iterator approach is that it avoids building the complete list
800- of all elements to be built in memory at once.
800+ of all elements in memory at once.
801801
802802``` erlang
803- 1 > S = gb_sets :from_ordset ([1 ,2 ,3 ,4 ,5 ]).
803+ 1 > S = gb_sets :from_list ([1 ,2 ,3 ,4 ,5 ]).
8048042 > Iter0 = gb_sets :iterator (S , ordered ).
8058053 > element (1 , gb_sets :next (Iter0 )).
8068061
@@ -837,25 +837,7 @@ iterator_r({_, _, R} = T, As) ->
837837iterator_r (nil , As ) ->
838838 As .
839839
840- -doc """
841- Returns an iterator that can be used for traversing the entries of ` Set ` ; see
842- ` next/1 ` .
843-
844- Unlike the iterator returned by ` iterator/1 ` or ` iterator/2 ` , this
845- iterator starts with the first element greater than or equal to
846- ` Element ` .
847-
848- Equivalent to [ ` iterator_from(Element, Set, ordered) ` ] ( `iterator_from/3` ) .
849-
850- ## Examples
851-
852- ``` erlang
853- 1 > S = gb_sets :from_ordset ([10 ,20 ,30 ,40 ,50 ]).
854- 2 > Iter = gb_sets :iterator_from (17 , S ).
855- 3 > element (1 , gb_sets :next (Iter )).
856- 20
857- ```
858- """ .
840+ -doc (#{equiv => iterator_from (Element , Set , ordered )}).
859841-doc (#{since => <<" OTP 18.0" >>}).
860842-spec iterator_from (Element , Set ) -> Iter when
861843 Set :: set (Element ),
@@ -865,19 +847,19 @@ iterator_from(Element, Set) ->
865847 iterator_from (Element , Set , ordered ).
866848
867849-doc """
868- Returns an iterator that can be used for traversing the entries of ` Set ` ; see
869- ` next/1 ` .
870-
871- Unlike the iterator returned by ` iterator/1 ` or ` iterator/2 ` , this
872- iterator starts with the first element greater than or equal to
873- ` Element ` .
850+ Returns an iterator over members of ` Set ` in the given ` Order ` , starting
851+ from ` Element ` or, if absent, the first member that follows in the
852+ iteration order, if any; see ` next/1 ` .
874853
875854## Examples
876855
877856``` erlang
878- 1 > S = gb_sets :from_ordset ([10 ,20 ,30 ,40 ,50 ]).
879- 2 > Iter = gb_sets :iterator_from (17 , S , reversed ).
880- 3 > element (1 , gb_sets :next (Iter )).
857+ 1 > S = gb_sets :from_list ([10 ,20 ,30 ,40 ,50 ]).
858+ 2 > Iter1 = gb_sets :iterator_from (17 , S , ordered ).
859+ 3 > element (1 , gb_sets :next (Iter1 )).
860+ 20
861+ 4 > Iter2 = gb_sets :iterator_from (17 , S , reversed ).
862+ 5 > element (1 , gb_sets :next (Iter2 )).
88186310
882864```
883865""" .
@@ -916,7 +898,7 @@ by iterator `Iter1`, and `Iter2` is the new iterator to be used for traversing
916898the remaining elements, or the atom ` none ` if no elements remain.
917899
918900``` erlang
919- 1 > S = gb_sets :from_ordset ([1 ,2 ,3 ,4 ,5 ]).
901+ 1 > S = gb_sets :from_list ([1 ,2 ,3 ,4 ,5 ]).
9209022 > Iter0 = gb_sets :iterator (S ).
9219033 > {Element0 , Iter1 } = gb_sets :next (Iter0 ).
9229044 > Element0 .
@@ -955,8 +937,8 @@ next({_, []}) ->
955937% % If the sets are not very different in size, i.e., if |Y| / |X| >= c *
956938% % log(|Y|), then the fastest way to do union (and the other similar set
957939% % operations) is to build the lists of elements, traverse these lists
958- % % in parallel while building a reversed ackumulator list, and finally
959- % % rebuild the tree directly from the ackumulator . Other methods of
940+ % % in parallel while building a reversed accumulator list, and finally
941+ % % rebuild the tree directly from the accumulator . Other methods of
960942% % traversing the elements can be devised, but they all have higher
961943% % overhead.
962944
@@ -1035,7 +1017,7 @@ union_1([], S) ->
10351017% % that the same is likely to apply to the next element also,
10361018% % statistically reducing the number of failed tests and automatically
10371019% % adapting to cases of lists having very different lengths. This saves
1038- % % 10-40% of the traversation time compared to a "fixed" strategy,
1020+ % % 10-40% of the traversal time compared to a "fixed" strategy,
10391021% % depending on the sizes and contents of the lists.
10401022% %
10411023% % 3) A tail recursive version using `lists:reverse/2' is about 5-10%
@@ -1092,15 +1074,15 @@ all sets, without duplicates.
10921074``` erlang
109310751 > S0 = gb_sets :from_list ([a ,b ,c ,d ]).
109410762 > S1 = gb_sets :from_list ([d ,e ,f ]).
1095- 3 > S2 = gb_sets :from_list ([q ,r ])
1077+ 3 > S2 = gb_sets :from_list ([q ,r ]).
109610784 > Sets = [S0 , S1 , S2 ].
109710795 > Union = gb_sets :union (Sets ).
109810806 > gb_sets :to_list (Union ).
10991081[a ,b ,c ,d ,e ,f ,q ,r ]
11001082```
11011083""" .
11021084-spec union (SetList ) -> Set when
1103- SetList :: [set (Element ),... ],
1085+ SetList :: [set (Element )],
11041086 Set :: set (Element ).
11051087
11061088union ([S | Ss ]) ->
@@ -1194,7 +1176,7 @@ elements that are present in all sets.
11941176``` erlang
119511771 > S0 = gb_sets :from_list ([a ,b ,c ,d ]).
119611782 > S1 = gb_sets :from_list ([d ,e ,f ]).
1197- 3 > S2 = gb_sets :from_list ([q ,r ])
1179+ 3 > S2 = gb_sets :from_list ([q ,r ]).
119811804 > Sets = [S0 , S1 , S2 ].
119911815 > gb_sets :to_list (gb_sets :intersection ([S0 , S1 , S2 ])).
12001182[]
@@ -1221,15 +1203,15 @@ Returns `true` if `Set1` and `Set2` are disjoint; otherwise, returns
12211203
12221204Two sets are disjoint if they have no elements in common.
12231205
1224- This function is equivalent to ` gb_sets:intersection(Set1, Set2) =:= [] ` ,
1206+ This function is equivalent to ` gb_sets:is_empty(gb_sets: intersection(Set1, Set2)) ` ,
12251207but faster.
12261208
12271209## Examples
12281210
12291211``` erlang
123012121 > S0 = gb_sets :from_list ([a ,b ,c ,d ]).
123112132 > S1 = gb_sets :from_list ([d ,e ,f ]).
1232- 3 > S2 = gb_sets :from_list ([q ,r ])
1214+ 3 > S2 = gb_sets :from_list ([q ,r ]).
123312154 > gb_sets :is_disjoint (S0 , S1 ).
12341216false
123512175 > gb_sets :is_disjoint (S1 , S2 ).
@@ -1493,13 +1475,13 @@ value, with `true` being equivalent to `{true, Elem}`.
14931475
14941476``` erlang
14951477filtermap (Fun , Set1 ) ->
1496- gb_sets :from_list (lists :filtermap (Fun , Set1 )).
1478+ gb_sets :from_list (lists :filtermap (Fun , gb_sets : to_list ( Set1 ) )).
14971479```
14981480
14991481## Examples
15001482
15011483``` erlang
1502- 1 > S = gb_sets :from_list ([2 ,4 ,5 ,6 ,8 ,9 ])
1484+ 1 > S = gb_sets :from_list ([2 ,4 ,5 ,6 ,8 ,9 ]).
150314852 > F = fun (X ) ->
15041486 case X rem 2 of
15051487 0 -> {true , X div 2 };
0 commit comments