public virtual ATerm setAnnotation(ATerm label, ATerm anno) { ATermList new_annos = annotations.dictPut(label, anno); ATerm result = setAnnotations(new_annos); return(result); }
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)); }
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()); }