Class SysPartitionSet
System-side implementation of the abstract base class PartitionSet, which declares the API for the developer.
Namespace: AS2.Sim
Assembly: .dll
Syntax
public class SysPartitionSet : PartitionSet
Constructors
| Edit this page View SourceSysPartitionSet(SysPinConfiguration, int, int)
Declaration
public SysPartitionSet(SysPinConfiguration pinConfig, int id, int size)
Parameters
Type | Name | Description |
---|---|---|
SysPinConfiguration | pinConfig | |
int | id | |
int | size |
Fields
| Edit this page View Sourcecircuit
The ID of the circuit this partition set currently belongs to.
Declaration
public int circuit
Field Value
Type | Description |
---|---|
int |
color
The color override of this partition set.
Declaration
public Color color
Field Value
Type | Description |
---|---|
Color |
colorOverride
Indicates whether the partition set has a color override.
Declaration
public bool colorOverride
Field Value
Type | Description |
---|---|
bool |
drawSingletonHandle
Indicates whether the partition set should always be drawn with a handle, even if it is a singleton set (but not if it is empty).
Declaration
public bool drawSingletonHandle
Field Value
Type | Description |
---|---|
bool |
id
The unique ID of this partition set within the pin configuration.
Declaration
public int id
Field Value
Type | Description |
---|---|
int |
numStoredPins
The number of pins contained in this partition set.
Declaration
private int numStoredPins
Field Value
Type | Description |
---|---|
int |
pinConfig
The pin configuration to which this partition set belongs.
Declaration
public SysPinConfiguration pinConfig
Field Value
Type | Description |
---|---|
SysPinConfiguration |
pins
A bit array indicating which pins are contained in this partition set. Indices are pin IDs.
Declaration
public BitArray pins
Field Value
Type | Description |
---|---|
BitArray |
positionHead
Global polar coordinates of this partition set in the particle's head.
Declaration
public Vector2 positionHead
Field Value
Type | Description |
---|---|
Vector2 |
positionTail
Global polar coordinates of this partition set in the particle's tail.
Declaration
public Vector2 positionTail
Field Value
Type | Description |
---|---|
Vector2 |
Properties
| Edit this page View SourceId
The ID of this partition set.
Partition set IDs range from 0
to
NumPins - 1
.
Declaration
public override int Id { get; }
Property Value
Type | Description |
---|---|
int |
Overrides
| Edit this page View SourceNumStoredPins
The number of pins contained in this partition set.
Declaration
public int NumStoredPins { get; }
Property Value
Type | Description |
---|---|
int |
PinConfiguration
The PinConfiguration to which this partition set belongs.
Declaration
public override PinConfiguration PinConfiguration { get; }
Property Value
Type | Description |
---|---|
PinConfiguration |
Overrides
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 override void AddPin(Pin pin)
Parameters
Type | Name | Description |
---|---|---|
Pin | pin | The pin to be added. |
Overrides
| Edit this page View SourceAddPin(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 override void AddPin(int idx)
Parameters
Type | Name | Description |
---|---|---|
int | idx |
Overrides
| Edit this page View SourceAddPinBasic(int)
Adds the pin with the given ID to this partition set without causing any further actions.
Used by PinConfiguration to handle pin movements.
Declaration
public void AddPinBasic(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 override void AddPins(Pin[] pins)
Parameters
Type | Name | Description |
---|---|---|
Pin[] | pins | An array containing the pins to be added. |
Overrides
| Edit this page View SourceAddPins(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 override void AddPins(int[] pinIds)
Parameters
Type | Name | Description |
---|---|---|
int[] | pinIds | An array containing the IDs of the pins to be added. |
Overrides
| Edit this page View SourceClearInternal()
Clears the local data of this partition set.
Note that if this partition set contains any pins, these pins will keep their references to this partition set.
Declaration
public void ClearInternal()
ContainsPin(Pin)
Checks if the given pin is contained in this partition set.
See also ContainsPin(int).
Declaration
public override bool ContainsPin(Pin pin)
Parameters
Type | Name | Description |
---|---|---|
Pin | pin | The pin to be checked. |
Returns
Type | Description |
---|---|
bool |
|
Overrides
| Edit this page View SourceContainsPin(int)
Checks if the specified pin is contained in this partition set.
See also ContainsPin(Pin).
Declaration
public override bool ContainsPin(int pinId)
Parameters
Type | Name | Description |
---|---|---|
int | pinId | The ID of the pin to be checked. |
Returns
Type | Description |
---|---|
bool |
|
Overrides
| Edit this page View SourceEquals(object)
Determines whether the specified object is equal to the current object.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to compare with the current object. |
Returns
Type | Description |
---|---|
bool | true if the specified object is equal to the current object; otherwise, false. |
Overrides
GetHashCode()
Serves as the default hash function.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | A hash code for the current object. |
Overrides
GetPinIds()
Returns the IDs of all pins contained in this partition set.
See also GetPins().
Declaration
public override int[] GetPinIds()
Returns
Type | Description |
---|---|
int[] | An array containing the IDs of all pins contained in this partition set, in ascending order. |
Overrides
| Edit this page View SourceGetPins()
Returns all pins contained in this partition set.
See also GetPinIds().
Declaration
public override Pin[] GetPins()
Returns
Type | Description |
---|---|
Pin[] | An array containing all pins contained in this partition set, ordered by their IDs. |
Overrides
| Edit this page View SourceGetReceivedMessage()
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 override Message GetReceivedMessage()
Returns
Type | Description |
---|---|
Message | The message received by this partition set in the
last round, if it exists, otherwise |
Overrides
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 override bool HasReceivedMessage()
Returns
Type | Description |
---|---|
bool |
|
Overrides
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 override bool IsEmpty()
Returns
Type | Description |
---|---|
bool |
|
Overrides
| Edit this page View SourceMerge(PartitionSet)
Merges the given partition set into this one.
Declaration
public override void Merge(PartitionSet other)
Parameters
Type | Name | Description |
---|---|---|
PartitionSet | other | The partition set whose pins should be moved to this set. |
Overrides
| Edit this page View SourceMerge(int)
Merges the specified partition set into this one.
Declaration
public override void Merge(int otherId)
Parameters
Type | Name | Description |
---|---|---|
int | otherId | The ID of the partition set whose pins should be moved to this set. |
Overrides
| Edit this page View SourcePrint()
Declaration
public string Print()
Returns
Type | Description |
---|---|
string |
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 override bool ReceivedBeep()
Returns
Type | Description |
---|---|
bool |
|
Overrides
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 override void RemovePin(Pin pin)
Parameters
Type | Name | Description |
---|---|---|
Pin | pin | The pin to be removed. |
Overrides
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 override void RemovePin(int idx)
Parameters
Type | Name | Description |
---|---|---|
int | idx |
Overrides
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown if the pin is the only one in this partition set and no other partition set is empty. |
RemovePinBasic(int)
Removes the pin with the given ID from this partition set without causing any further actions.
Used by PinConfiguration to handle pin movements.
Declaration
public void RemovePinBasic(int pinId)
Parameters
Type | Name | Description |
---|---|---|
int | pinId | The ID of the pin to be removed. |
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 override void RemovePins(Pin[] pins)
Parameters
Type | Name | Description |
---|---|---|
Pin[] | pins | An array containing the pins to be removed. |
Overrides
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 override void RemovePins(int[] pinIds)
Parameters
Type | Name | Description |
---|---|---|
int[] | pinIds | An array containing the IDs of the pins to be removed. |
Overrides
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 override void ResetColor()
Overrides
| Edit this page View SourceSendBeep()
Sends a beep on this partition set if the pin configuration it belongs to is the next one.
Declaration
public override void SendBeep()
Overrides
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 override void SendMessage(Message msg)
Parameters
Type | Name | Description |
---|---|---|
Message | msg | The message to be sent. |
Overrides
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 override void SetColor(Color color)
Parameters
Type | Name | Description |
---|---|---|
Color | color | The color in which to display this partition set. |
Overrides
| Edit this page View SourceSetDrawHandle(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 override void SetDrawHandle(bool drawHandle)
Parameters
Type | Name | Description |
---|---|---|
bool | drawHandle | Whether the handle should always be drawn. |
Overrides
| Edit this page View SourceSetPosition(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 override 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 |
Overrides
Operators
| Edit this page View Sourceoperator ==(SysPartitionSet, SysPartitionSet)
Declaration
public static bool operator ==(SysPartitionSet p1, SysPartitionSet p2)
Parameters
Type | Name | Description |
---|---|---|
SysPartitionSet | p1 | |
SysPartitionSet | p2 |
Returns
Type | Description |
---|---|
bool |
operator !=(SysPartitionSet, SysPartitionSet)
Declaration
public static bool operator !=(SysPartitionSet p1, SysPartitionSet p2)
Parameters
Type | Name | Description |
---|---|---|
SysPartitionSet | p1 | |
SysPartitionSet | p2 |
Returns
Type | Description |
---|---|
bool |