Class PartitionSet
Developer API for partition sets.
This is part of the pin configuration API, see PinConfiguration.
A partition set is a set of connected pins within
a pin configuration. It belongs to an object
implementing the PinConfiguration
interface and may be changed through methods of
this API or through the pin configuration itself.
See also Pin.
Namespace: AS2.Sim
Assembly: .dll
Syntax
public abstract class PartitionSet
Properties
| Edit this page View SourceId
The ID of this partition set.
Partition set IDs range from 0
to
NumPins - 1
.
Declaration
public abstract int Id { get; }
Property Value
Type | Description |
---|---|
int |
PinConfiguration
The PinConfiguration to which this partition set belongs.
Declaration
public abstract PinConfiguration PinConfiguration { get; }
Property Value
Type | Description |
---|---|
PinConfiguration |
Methods
| Edit this page View SourceAddPin(Pin)
Adds the given pin to this partition set.
If the pin is not already contained in this set, it is removed from the set it is currently contained in.
See also AddPin(int).
Declaration
public abstract void AddPin(Pin pin)
Parameters
Type | Name | Description |
---|---|---|
Pin | pin | The pin to be added. |
AddPin(int)
Adds the specified pin to this partition set.
If the pin is not already contained in this set, it is removed from the set it is currently contained in.
See also AddPin(Pin).
Declaration
public abstract void AddPin(int pinId)
Parameters
Type | Name | Description |
---|---|---|
int | pinId | The ID of the pin to be added. |
AddPins(Pin[])
Adds the given pins to this partition set.
Has the same effect as calling AddPin(Pin) multiple times.
See also AddPins(int[]).
Declaration
public abstract void AddPins(Pin[] pins)
Parameters
Type | Name | Description |
---|---|---|
Pin[] | pins | An array containing the pins to be added. |
AddPins(int[])
Adds the specified pins to this partition set.
Has the same effect as calling AddPin(int) multiple times.
See also AddPins(Pin[]).
Declaration
public abstract void AddPins(int[] pinIds)
Parameters
Type | Name | Description |
---|---|---|
int[] | pinIds | An array containing the IDs of the pins to be added. |
ContainsPin(Pin)
Checks if the given pin is contained in this partition set.
See also ContainsPin(int).
Declaration
public abstract bool ContainsPin(Pin pin)
Parameters
Type | Name | Description |
---|---|---|
Pin | pin | The pin to be checked. |
Returns
Type | Description |
---|---|
bool |
|
ContainsPin(int)
Checks if the specified pin is contained in this partition set.
See also ContainsPin(Pin).
Declaration
public abstract bool ContainsPin(int pinId)
Parameters
Type | Name | Description |
---|---|---|
int | pinId | The ID of the pin to be checked. |
Returns
Type | Description |
---|---|
bool |
|
GetPinIds()
Returns the IDs of all pins contained in this partition set.
See also GetPins().
Declaration
public abstract int[] GetPinIds()
Returns
Type | Description |
---|---|
int[] | An array containing the IDs of all pins contained in this partition set, in ascending order. |
GetPins()
Returns all pins contained in this partition set.
See also GetPinIds().
Declaration
public abstract Pin[] GetPins()
Returns
Type | Description |
---|---|
Pin[] | An array containing all pins contained in this partition set, ordered by their IDs. |
GetReceivedMessage()
Returns the message this partition set has received in the last round, if it has received one and it belongs to the current pin configuration.
Declaration
public abstract Message GetReceivedMessage()
Returns
Type | Description |
---|---|
Message | The message received by this partition set in the
last round, if it exists, otherwise |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown if this partition set does not belong to the current pin configuration. |
HasReceivedMessage()
Checks whether this partition set has received a message in the last round, if the pin configuration it belongs to is the current one.
Declaration
public abstract bool HasReceivedMessage()
Returns
Type | Description |
---|---|
bool |
|
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown if this partition set does not belong to the current pin configuration. |
IsEmpty()
Checks if this partition set is empty.
Declaration
public abstract bool IsEmpty()
Returns
Type | Description |
---|---|
bool |
|
Merge(PartitionSet)
Merges the given partition set into this one.
Declaration
public abstract void Merge(PartitionSet other)
Parameters
Type | Name | Description |
---|---|---|
PartitionSet | other | The partition set whose pins should be moved to this set. |
Merge(int)
Merges the specified partition set into this one.
Declaration
public abstract void Merge(int otherId)
Parameters
Type | Name | Description |
---|---|---|
int | otherId | The ID of the partition set whose pins should be moved to this set. |
ReceivedBeep()
Checks whether this partition set has received a beep in the last round, if the pin configuration it belongs to is the current one.
Declaration
public abstract bool ReceivedBeep()
Returns
Type | Description |
---|---|
bool |
|
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown if this partition set does not belong to the current pin configuration. |
RemovePin(Pin)
Tries to remove the specified pin from this partition set.
If the pin is currently contained in this partition set and some other partition set is currently empty, the pin is moved to that empty partition set. If no empty partition set can be found, an exception will be thrown.
See also RemovePin(int).
Declaration
public abstract void RemovePin(Pin pin)
Parameters
Type | Name | Description |
---|---|---|
Pin | pin | The pin to be removed. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown if the pin is the only one in this partition set and no other partition set is empty. |
RemovePin(int)
Tries to remove the specified pin from this partition set.
If the pin is currently contained in this partition set and some other partition set is currently empty, the pin is moved to that empty partition set. If no empty partition set can be found, an exception will be thrown.
See also RemovePin(Pin).
Declaration
public abstract void RemovePin(int pinId)
Parameters
Type | Name | Description |
---|---|---|
int | pinId | The ID of the pin to be removed. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown if the pin is the only one in this partition set and no other partition set is empty. |
RemovePins(Pin[])
Tries to remove the given pins from this partition set.
Has the same effect as calling RemovePin(Pin) multiple times.
See also RemovePins(int[]).
Declaration
public abstract void RemovePins(Pin[] pins)
Parameters
Type | Name | Description |
---|---|---|
Pin[] | pins | An array containing the pins to be removed. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown if a pin is the last one in this partition set and no other partition set is empty. |
RemovePins(int[])
Tries to remove the specified pins from this partition set.
Has the same effect as calling RemovePin(int) multiple times.
See also RemovePins(Pin[]).
Declaration
public abstract void RemovePins(int[] pinIds)
Parameters
Type | Name | Description |
---|---|---|
int[] | pinIds | An array containing the IDs of the pins to be removed. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown if a pin is the last one in this partition set and no other partition set is empty. |
ResetColor()
Resets the color override of this partition set.
Declaration
public abstract void ResetColor()
SendBeep()
Sends a beep on this partition set if the pin configuration it belongs to is the next one.
Declaration
public abstract void SendBeep()
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown if this partition set does not belong to the next pin configuration. |
SendMessage(Message)
Sends a message on this partition set if the pin configuration it belongs to is the next one.
Declaration
public abstract void SendMessage(Message msg)
Parameters
Type | Name | Description |
---|---|---|
Message | msg | The message to be sent. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown if this partition set does not belong to the next pin configuration. |
SetColor(Color)
Overrides the color of this partition set.
Declaration
public abstract void SetColor(Color color)
Parameters
Type | Name | Description |
---|---|---|
Color | color | The color in which to display this partition set. |
SetDrawHandle(bool)
Specifies whether this partition set should always be drawn with a handle, even if it is a singleton set (but not if it is empty).
Declaration
public abstract void SetDrawHandle(bool drawHandle)
Parameters
Type | Name | Description |
---|---|---|
bool | drawHandle | Whether the handle should always be drawn. |
SetPosition(Vector2, bool)
Sets the position of this partition set to the given polar coordinates. Only affects the position if the partition set contains at least two pins. Also sets the pin configuration's placement mode to MANUAL.
Declaration
public abstract void SetPosition(Vector2 polarCoords, bool head = true)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | polarCoords | The polar coordinates
|
bool | head | Determines whether the partition set in
the particle's head or tail should be placed. For
contracted particles, this should be |