共用方式為


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) 成員都是執行緒安全的。並不是所有的執行個體成員都保證可以用於所有的執行緒。