Skip to content

Pattern Class

sequenze edited this page Jun 19, 2017 · 4 revisions

Concrete implementation of a pattern. Provides the primitives required to define a pattern.

Inheritance Hierarchy

Object

Syntax

public sealed class Pattern : IPattern, IFields

Properties

Name               Description
Fields Gets or sets the underlying array of values representing the pattern.
Size Returns the size of the pattern.
Item[Int32] Gets or sets the i'th element of the pattern.

Constructors

Name                           Description
Pattern(Object[]) Initializes a new instance of the Pattern class.

Remarks

Pattern is the concretization of IPattern. While dotSpace allow one to directly specify the pattern, one also have the option of instantiating a Pattern object. This is usefull if the pattern is used at multiple occasions, as it provides better clarity for the read of the code.

Examples

The following example demonstrates the usage of Pattern for fetching data from a tuple space.

    static void Main(string[] args)
    {
        FifoSpace fridge = new FifoSpace();
        fridge.Put("Milk", 3);
        Pattern pattern = new Pattern("Milk", typeof(int));
        ITuple result = fridge.Query(pattern);
        Console.WriteLine("The fridge has {0} bottles of {1}", result[1], result[0]);
        Console.Read();
    }
    /*
    The following is printed to the console:
    The fridge has 3 bottles of Milk
    */

See Also

IPattern, IFields

Clone this wiki locally