We recommend using Visual Studio 2017
SetBuilder Class
Provides the functionality to create immutable sets.
Namespace: Microsoft.AnalysisServices.AdomdServer
Assembly: msmgdsrv (in msmgdsrv.dll)
The SetBuilder type exposes the following members.
Name | Description | |
---|---|---|
![]() | SetBuilder() | Initializes a new instance of the SetBuilder class. |
![]() | SetBuilder(Tuple) | Initializes a new instance of the SetBuilder class, with a given Tuple. |
Name | Description | |
---|---|---|
![]() | {dtor} | Releases all resources used by the SetBuilder. |
![]() | Add | Adds a Tuple to the set. |
![]() | Dispose | Releases all resources used by the SetBuilder. |
![]() | Equals | (Inherited from Object.) |
![]() | GetHashCode | (Inherited from Object.) |
![]() | GetType | (Inherited from Object.) |
![]() | ToSet | Gets a Set based on the specified Tuple objects. |
![]() | ToString | (Inherited from Object.) |
The following example takes a set and a count that indicates the number of tuples to return, and randomly retrieves tuples from the set, returning a final subset.
public Set RandomSample(Set set, int returnCount) { //Return the original set if there are fewer tuples //in the set than the number requested. if (set.Tuples.Count <= returnCount) return set; System.Random r = new System.Random(); SetBuilder returnSet = new SetBuilder(); //Retrieve random tuples until the return set is filled. int i = set.Tuples.Count; foreach (Tuple t in set.Tuples) { if (r.Next(i) < returnCount) { returnCount--; returnSet.Add(t); } i--; //Stop the loop if we have enough tuples. if (returnCount == 0) break; } return returnSet.ToSet(); }
Show: