예제 #1
0
        public virtual ATerm setAnnotation(ATerm label, ATerm anno)
        {
            ATermList new_annos = annotations.dictPut(label, anno);
            ATerm     result    = setAnnotations(new_annos);

            return(result);
        }
예제 #2
0
        public virtual void TestDict()
        {
            factory = Tester.theFactory;
            ATermList dict = factory.makeList();
            ATerm     key, value;

            for (int i = 0; i < 5; i++)
            {
                key   = factory.parse("key" + i);
                value = factory.parse("value" + i);
                dict  = dict.dictPut(key, value);
            }

            key   = factory.parse("key3");
            value = factory.parse("value3");
            AssertTrue(dict.dictGet(key).Equals(value));
        }
예제 #3
0
        public virtual ATermList dictPut(ATerm key, ATerm value)
        {
            ATermList pair;

            if (isEmpty())
            {
                pair = getEmpty().insert(value).insert(key);
                return(getEmpty().insert(pair));
            }

            pair = (ATermList)first;

            if (key.equals(pair.getFirst()))
            {
                pair = getEmpty().insert(value).insert(pair);
                return(next.insert(pair));
            }

            return((ATermList)next.dictPut(key, value).insert(first).setAnnotations(getAnnotations()));
            //return getPureFactory().makeList(first, next.dictPut(key, value), getAnnotations());
        }