Exemple #1
0
 public void Write(TProtocol oprot)
 {
     oprot.IncrementRecursionDepth();
     try
     {
         TStruct struc = new TStruct("DataUnit");
         oprot.WriteStructBegin(struc);
         TField field = new TField();
         if (Person_property != null && __isset.person_property)
         {
             field.Name = "person_property";
             field.Type = TType.Struct;
             field.ID   = 1;
             oprot.WriteFieldBegin(field);
             Person_property.Write(oprot);
             oprot.WriteFieldEnd();
         }
         if (Page_property != null && __isset.page_property)
         {
             field.Name = "page_property";
             field.Type = TType.Struct;
             field.ID   = 2;
             oprot.WriteFieldBegin(field);
             Page_property.Write(oprot);
             oprot.WriteFieldEnd();
         }
         if (Equiv != null && __isset.equiv)
         {
             field.Name = "equiv";
             field.Type = TType.Struct;
             field.ID   = 3;
             oprot.WriteFieldBegin(field);
             Equiv.Write(oprot);
             oprot.WriteFieldEnd();
         }
         if (Page_view != null && __isset.page_view)
         {
             field.Name = "page_view";
             field.Type = TType.Struct;
             field.ID   = 4;
             oprot.WriteFieldBegin(field);
             Page_view.Write(oprot);
             oprot.WriteFieldEnd();
         }
         oprot.WriteFieldStop();
         oprot.WriteStructEnd();
     }
     finally
     {
         oprot.DecrementRecursionDepth();
     }
 }
Exemple #2
0
    public override string ToString()
    {
        StringBuilder __sb    = new StringBuilder("DataUnit(");
        bool          __first = true;

        if (Person_property != null && __isset.person_property)
        {
            if (!__first)
            {
                __sb.Append(", ");
            }
            __first = false;
            __sb.Append("Person_property: ");
            __sb.Append(Person_property == null ? "<null>" : Person_property.ToString());
        }
        if (Page_property != null && __isset.page_property)
        {
            if (!__first)
            {
                __sb.Append(", ");
            }
            __first = false;
            __sb.Append("Page_property: ");
            __sb.Append(Page_property == null ? "<null>" : Page_property.ToString());
        }
        if (Equiv != null && __isset.equiv)
        {
            if (!__first)
            {
                __sb.Append(", ");
            }
            __first = false;
            __sb.Append("Equiv: ");
            __sb.Append(Equiv == null ? "<null>" : Equiv.ToString());
        }
        if (Page_view != null && __isset.page_view)
        {
            if (!__first)
            {
                __sb.Append(", ");
            }
            __first = false;
            __sb.Append("Page_view: ");
            __sb.Append(Page_view == null ? "<null>" : Page_view.ToString());
        }
        __sb.Append(")");
        return(__sb.ToString());
    }
Exemple #3
0
    public static void perm0_to_equiv_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    PERM0_TO_EQUIV_TEST tests PERM0_TO_EQUIV.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    15 June 2015
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int[]     a      = new int[9];
        int[]     jarray = new int[9];
        const int n      = 9;
        int       npart  = 0;

        int[] p = { 1, 2, 8, 5, 6, 7, 4, 3, 0 };

        Console.WriteLine("");
        Console.WriteLine("PERM0_TO_EQUIV_TEST");
        Console.WriteLine("  PERM0_TO_EQUIV returns the set partition");
        Console.WriteLine("  or equivalence classes determined by a");
        Console.WriteLine("  permutation of (0,...,N-1).");

        Permutation.perm0_print(n, p, "  The input permutation:");

        Permutation.perm0_to_equiv(n, p, ref npart, ref jarray, ref a);

        Equiv.equiv_print(n, a, "  The partition:");
    }
    public static void equiv_random_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    EQUIV_RANDOM_TEST tests EQUIV_RANDOM.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    15 May 2009
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int[]     a = new int[4];
        int       i;
        const int n     = 4;
        int       npart = 0;

        Console.WriteLine("");
        Console.WriteLine("EQUIV_RANDOM_TEST");
        Console.WriteLine("  EQUIV_RANDOM selects a random set partition.");

        int seed = 123456789;

        for (i = 1; i <= 5; i++)
        {
            Equiv.equiv_random(n, ref seed, ref npart, ref a);

            Equiv.equiv_print(n, a, "  The partition:");
        }
    }
Exemple #5
0
    private PLS CreateExpression(int size)
    {
        PLS predicate = CreateUnaryExpression();
        int sizeLeft  = size;

        if (sizeLeft > 0)
        {
            int j      = Random.Range(0, 4);
            PLS newExp = CreateExpression(sizeLeft - 1);
            switch (j)
            {
            case 0:
                predicate = new And(predicate, newExp);
                break;

            case 1:
                predicate = new Or(predicate, newExp);
                break;

            case 2:
                predicate = new To(predicate, newExp);
                break;

            case 3:
                predicate = new Equiv(predicate, newExp);
                break;
            }
        }
        int i = Random.Range(0, 2);

        if (i > 0)
        {
            predicate = new Neg(predicate);
        }
        return(predicate);
    }
    public static void equiv_next2_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    EQUIV_NEXT2_TEST tests EQUIV_NEXT2.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    20 January 2007
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        const int N = 4;

        int[] a = new int[N];
        int   i;

        Console.WriteLine("");
        Console.WriteLine("EQUIV_NEXT2_TEST");
        Console.WriteLine("  EQUIV_NEXT2 generates all partitions of a set.");
        Console.WriteLine("");
        Console.WriteLine("  Rank//element:");
        Console.WriteLine("");
        string cout = "      ";

        for (i = 1; i <= N; i++)
        {
            cout += i.ToString().PadLeft(2) + "  ";
        }

        Console.WriteLine(cout);
        Console.WriteLine("");

        int  rank = 0;
        bool done = true;

        for (;;)
        {
            Equiv.equiv_next2(ref done, ref a, N);

            if (done)
            {
                break;
            }

            rank += 1;

            cout = "  "
                   + rank.ToString().PadLeft(2) + "  ";
            for (i = 0; i < N; i++)
            {
                cout += a[i].ToString().PadLeft(2) + "  ";
            }

            Console.WriteLine(cout);
        }
    }