• Guides
  • Api Documentation
Show / Hide Table of Contents
  • Discord.Addons.MpGame
    • CurrentlyPlaying
    • GameBase<TPlayer>
    • IMpGameData
    • MpGameModuleBase<TService, TGame, TPlayer>
    • MpGameService<TGame, TPlayer>
    • MpGameService<TGame, TPlayer>.MpGameData
    • Player
  • Discord.Addons.MpGame.Collections
    • CircularLinkedList<T>
    • Hand<T>
    • IWrapper<T>
    • Node<T>
    • Pile<T>
    • WrappingPile<T, TWrapper>
  • Discord.Addons.Preconditions
    • Measure
    • MinimumOnlineUsersAttribute
    • RatelimitAttribute
    • RatelimitFlags
    • RequireLowerHierarchyAttribute
    • RequireRoleAttribute
    • UserMustBeInVoiceAttribute

Class Hand<T>

Similar to Pile<T> but specialized and optimized for representing a hand of items.

Inheritance
Object
Hand<T>
Namespace: Discord.Addons.MpGame.Collections
Assembly: Discord.Addons.MpGame.dll
Syntax
public sealed class Hand<T>
    where T : class
Type Parameters
Name Description
T

The item type.

Constructors

| Improve this Doc View Source

Hand()

Initializes a new Hand<T> to an empty state.

Declaration
public Hand()
| Improve this Doc View Source

Hand(IEnumerable<T>)

Initializes a new Hand<T> with the specified items.

Declaration
public Hand(IEnumerable<T> items)
Parameters
Type Name Description
IEnumerable<T> items

The items to put in the hand.

Remarks
note

This constructor will filter out any items in items that are null or are pointing to the same object instance.

Exceptions
Type Condition
ArgumentNullException

items was null.

Properties

| Improve this Doc View Source

Count

The amount of items currently in the hand.

Declaration
public int Count { get; }
Property Value
Type Description
Int32

Methods

| Improve this Doc View Source

Add(T)

Adds an item to the hand.

Declaration
public void Add(T item)
Parameters
Type Name Description
T item

The item to add.

Exceptions
Type Condition
ArgumentNullException

item was null.

| Improve this Doc View Source

AddRange(IEnumerable<T>)

Adds multiple items to the hand.

Declaration
public void AddRange(IEnumerable<T> items)
Parameters
Type Name Description
IEnumerable<T> items

The items to add.

Exceptions
Type Condition
ArgumentNullException

items was null.

| Improve this Doc View Source

AsIndexed()

Creates a snapshot if the items inside this hand with its respective 0-based index.

Declaration
public ImmutableArray<(int, T)> AsIndexed()
Returns
Type Description
ImmutableArray<(T1, T2)<Int32, T>>
| Improve this Doc View Source

Browse()

The items inside this hand.

Declaration
public ImmutableArray<T> Browse()
Returns
Type Description
ImmutableArray<T>
| Improve this Doc View Source

Clear()

Clears the entire hand and returns the items that were in it.

Declaration
public ImmutableArray<T> Clear()
Returns
Type Description
ImmutableArray<T>

The collection as it was before it is cleared.

| Improve this Doc View Source

Order(Func<ImmutableArray<T>, IEnumerable<T>>)

Orders the items using the specified function.

Declaration
public void Order(Func<ImmutableArray<T>, IEnumerable<T>> orderFunc)
Parameters
Type Name Description
Func<ImmutableArray<T>, IEnumerable<T>> orderFunc

A function that produces an IEnumerable<T> in a new order.
This function receives the items currently in the hand as its argument.

Exceptions
Type Condition
ArgumentNullException

orderFunc was null.

InvalidOperationException

The sequence produced from orderFunc was null.

| Improve this Doc View Source

TakeAt(Int32)

Takes a item from the given index.

Declaration
public T TakeAt(int index)
Parameters
Type Name Description
Int32 index

The 0-based index of the item to take.

Returns
Type Description
T
Exceptions
Type Condition
ArgumentOutOfRangeException

index was less than 0 or greater than or equal to the hand's current size.

| Improve this Doc View Source

TakeFirstOrDefault(Func<T, Boolean>)

Takes the first item that matches a given predicate.

Declaration
public T TakeFirstOrDefault(Func<T, bool> predicate)
Parameters
Type Name Description
Func<T, Boolean> predicate

The predicate to match.

Returns
Type Description
T

The first item to match the given predicate, or null if no match found.

Exceptions
Type Condition
ArgumentNullException

predicate was null.

  • Improve this Doc
  • View Source
Back to top Generated by DocFX