Поделиться через


Класс 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();
}

Безопасность многопоточности

Любые открытые статический (Shared в Visual Basic) элементы этого типа потокобезопасны. Потокобезопасность с элементами экземпляров не гарантируется.