@@ -11,7 +11,7 @@ Sets require a min PHP version of 7.1.
1111
1212* [ Installation] ( #installation )
1313* [ ** Basic usage:** ] ( #basic-usage )
14- * [ Creating a Set] ( #creating )
14+ * [ Creating a Set] ( #creating-a-set )
1515 * [ Adding values] ( #adding-values )
1616 * [ Removing values] ( #removing-values )
1717 * [ Testing if a value is present] ( #testing-if-a-value-is-present )
@@ -20,16 +20,15 @@ Sets require a min PHP version of 7.1.
2020 * [ As a traditional Array] ( #as-a-traditional-array )
2121 * [ Using ` entries() ` ] ( #using-entries )
2222 * [ Using ` each ` ] ( #using-eachcallback-args )
23- * [ Using ` values ` ] ( #using-values )
2423* [ ** Set operations** ] ( #set-operations )
2524 * [ Union] ( #union )
2625 * [ Difference] ( #difference )
2726 * [ Symmetric difference] ( #symmetric-difference )
2827 * [ Intersect] ( #intersect )
2928 * [ Subsets] ( #subsets )
3029* [ ** Set family operations** ] ( #set-family-operations )
31- * [ UnionOfArray ] ( #union-of-array )
32- * [ IntersectionOfArray ] ( #intersection-of-array )
30+ * [ Family Union ] ( #union-of-a-family-of-sets )
31+ * [ Family Intersection ] ( #intersection-of-a-family-of-sets )
3332
3433## Installation
3534You can download the latest release via the releases link on this page.
@@ -64,9 +63,12 @@ Sets cannot contain duplicate values, and values are stored in insertion order.
6463$set = new Set(1, 2, 1, 3, 2);
6564````
6665
67- If you have an array of elements, you can create a set containing those values .
66+ If you have an array of elements, you can either pass in the array directly, or splat the array .
6867``` php
69- $set = Set::FromArray([1, 2, 3]);
68+ $set = new Set([1, 2, 1, 3, 2]);
69+
70+ $array = [1, 2, 1, 3, 2];
71+ $set = new Set(...$array);
7072```
7173
7274#### Adding values
@@ -166,6 +168,8 @@ foreach ($set as $val) {
166168}
167169````
168170
171+ Or if you want, you can iterate ` $set->values() ` instead.
172+
169173#### Using ` entries() `
170174The ` entries() ` method returns an [ ArrayIterator] ( http://php.net/manual/en/class.arrayiterator.php ) object.
171175```` php
@@ -265,33 +269,30 @@ and welcome.
265269
266270#### Union of a Family of Sets
267271
268- At present the family of sets needs to be in an array of ` Set ` s.
269- Then we pass that array of sets to ` Set::UnionOfArray() ` .
270- For example:
272+ At present the family of sets needs to be in an array of ` Set ` objects:
271273``` php
272- $set1 = Set(1,2,3);
273- $set2 = Set(3,4,5);
274- $set_family = [ $set1, $set2 ];
275- $set_union = Set::UnionOfArray($set_family);
274+ $set1 = Set(1, 2, 3);
275+ $set2 = Set(3, 4, 5);
276+ $set2 = Set(5, 1, 6);
277+
278+ $set_union = Set::familyUnion([$set1, $set2]); // [1, 2, 3, 4, 5, 6]
276279```
277280
278281#### Intersection of a Family of Sets
279282
280- As with ` UnionOfArray ` , the family of sets needs to be in an array of ` Set ` s.
281- Then pass that array of sets to ` Set::IntersectionOfArray() ` .
282- For example:
283+ As with ` familyUnion ` , the family of sets needs to be in an array of ` Set ` objects:
283284``` php
284285$set1 = Set(1,2,3);
285286$set2 = Set(3,4,5);
286287$set_family = [ $set1, $set2 ];
287- $set_intersection = Set::IntersectionOfArray ($set_family);
288+ $set_intersection = Set::familyIntersection ($set_family);
288289```
289290
290291Note that, contrary to Set Theory, the result of
291292taking the intersection of an empty array results
292293in an empty array. (In Set Theory the intersection
293294of an empty family is undefined as it would be the
294- 'set of all sets'.)
295+ [ 'set of all sets'] ( https://en.wikipedia.org/wiki/Universal_set ) .)
295296
296297### Contributing
297298Contributions and changes welcome! Just open an issue or submit a PR :muscle :
0 commit comments