Sdílet prostřednictvím


SetBuilder Class

Provides the functionality to create immutable sets.

Inheritance Hierarchy

System.Object
  Microsoft.AnalysisServices.AdomdServer.SetBuilder

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

Syntax

'Declaration
Public NotInheritable Class SetBuilder _
    Implements IDisposable
'Usage
Dim instance As SetBuilder
public sealed class SetBuilder : IDisposable
public ref class SetBuilder sealed : IDisposable
[<SealedAttribute>]
type SetBuilder =  
    class
        interface IDisposable
    end
public final class SetBuilder implements IDisposable

The SetBuilder type exposes the following members.

Constructors

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

Top

Properties

  Name Description
Public property Count Gets the number of Tuple objects in the set.
Public property Item Gets the specified Tuple object.

Top

Methods

  Name Description
Public method {dtor} Releases all resources used by the SetBuilder.
Public method Add Adds a Tuple to the set.
Public method Dispose Releases all resources used by the SetBuilder.
Public method Equals (Inherited from Object.)
Protected method Finalize (Inherited from Object.)
Public method GetHashCode (Inherited from Object.)
Public method GetType (Inherited from Object.)
Protected method MemberwiseClone (Inherited from Object.)
Public method ToSet Gets a Set based on the specified Tuple objects.
Public method ToString (Inherited from Object.)

Top

Examples

The following example takes a set and a return count, 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();
}

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.