From a4d5a75ba7cb95614587fc7bfe2b2213c125c056 Mon Sep 17 00:00:00 2001 From: Fernando Lima Date: Mon, 12 Dec 2016 13:59:09 -0300 Subject: [PATCH] Added ToArray() method ToArray returns the set as an array of elements. I don't know if I used mapped types correctly, but at Java you just use toArray(), at .net you have ToArray(Of T) and at Cooca we need to call objectEnumerator().allObjects Sometimes I have the necessity of get the elements of the set, then I added this function to do this. I hope you can add it to Sugar. --- Sugar/Collections/HashSet.pas | 1 + 1 file changed, 1 insertion(+) diff --git a/Sugar/Collections/HashSet.pas b/Sugar/Collections/HashSet.pas index d58079dc..b551a2e6 100644 --- a/Sugar/Collections/HashSet.pas +++ b/Sugar/Collections/HashSet.pas @@ -13,6 +13,7 @@ interface method Contains(Item: T): Boolean; method &Remove(Item: T): Boolean; method ForEach(Action: Action); + method ToArray(); mapped to {$IF COOPER OR ECHOES}ToArray{$ELSE}objectEnumerator().allObjects{$ENDIF}; method Intersect(&Set: HashSet); method &Union(&Set: HashSet);