Export (0) Print
Expand All

SetBuilder Class

Provides the functionality to create immutable sets.


Namespace:  Microsoft.AnalysisServices.AdomdServer
Assembly:  msmgdsrv (in msmgdsrv.dll)

public sealed class SetBuilder : IDisposable

The SetBuilder type exposes the following members.

Public methodSetBuilder()Initializes a new instance of the SetBuilder class.
Public methodSetBuilder(Tuple)Initializes a new instance of the SetBuilder class, with a given Tuple.

Public propertyCountGets the number of Tuple objects in the set.
Public propertyItemGets the specified Tuple object.

Public method{dtor}Releases all resources used by the SetBuilder.
Public methodAddAdds a Tuple to the set.
Public methodDisposeReleases all resources used by the SetBuilder.
Public methodEquals (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Public methodToSetGets a Set based on the specified Tuple objects.
Public methodToString (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)
        //Stop the loop if we have enough tuples.
        if (returnCount == 0)
    return returnSet.ToSet();

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft