SetBuilder 类

Provides the functionality to create immutable sets.

继承层次结构

System. . :: . .Object
  Microsoft.AnalysisServices.AdomdServer..::..SetBuilder

命名空间:  Microsoft.AnalysisServices.AdomdServer
程序集:  msmgdsrv(在 msmgdsrv.dll 中)

语法

声明
Public NotInheritable Class SetBuilder _
    Implements IDisposable
用法
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

SetBuilder 类型公开以下成员。

构造函数

  名称 说明
公共方法 SetBuilder() () () () Initializes a new instance of the SetBuilder class.
公共方法 SetBuilder(Tuple) Initializes a new instance of the SetBuilder class, with a given Tuple.

页首

属性

  名称 说明
公共属性 Count Gets the number of Tuple objects in the set.
公共属性 Item Gets the specified Tuple object.

页首

方法

  名称 说明
公共方法 {dtor} Releases all resources used by the SetBuilder.
公共方法 Add Adds a Tuple to the set.
公共方法 Dispose Releases all resources used by the SetBuilder.
公共方法 Equals (从 Object 继承。)
受保护方法 Finalize (从 Object 继承。)
公共方法 GetHashCode (从 Object 继承。)
公共方法 GetType (从 Object 继承。)
受保护方法 MemberwiseClone (从 Object 继承。)
公共方法 ToSet Gets a Set based on the specified Tuple objects.
公共方法 ToString (从 Object 继承。)

页首

示例

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();
}

线程安全

此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。不保证所有实例成员都是线程安全的。