Changeset d3e4d6c for src/tests/avltree


Ignore:
Timestamp:
Aug 23, 2017, 6:22:07 PM (8 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, stuck-waitfor-destruct, with_gc
Children:
87e08e24, cb811ac
Parents:
9f07232 (diff), bd37119 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg2:software/cfa/cfa-cc

Location:
src/tests/avltree
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/tests/avltree/avl.h

    r9f07232 rd3e4d6c  
    2121// xxx - unbound type variable problems when trying to use new instead of create
    2222// forall( otype T, ttype Params | { void ?{}(T *, Params); } ) T * new( Params p );
    23 
    24 forall(dtype T | { void ^?{}(T *); })
    25 void delete(T * x);
    2623
    2724// To-do: properly use height or balance factor
     
    5855
    5956forall(otype K | Comparable(K), otype V)
    60 void ?{}(tree(K, V) *t, K key, V value);
     57void ?{}(tree(K, V) &t, K key, V value);
    6158
    6259forall(otype K, otype V)
    63 void ^?{}(tree(K, V) * t);
     60void ^?{}(tree(K, V) & t);
    6461
    6562forall(otype K | Comparable(K), otype V)
  • src/tests/avltree/avl1.c

    r9f07232 rd3e4d6c  
    11#include "avl.h"
    22// #include "cwrap.h"
     3#include <stdlib>
    34
    45forall(otype K | Comparable(K), otype V)
    5 void ?{}(tree(K, V) *t, K key, V value){
    6   (&t->key) { key };
    7   (&t->value) { value };
    8   t->parent = NULL;
    9   t->left = NULL;
    10   t->right = NULL;
    11   t->balance = 0;
     6void ?{}(tree(K, V) &t, K key, V value){
     7  (t.key) { key };
     8  (t.value) { value };
     9  t.parent = NULL;
     10  t.left = NULL;
     11  t.right = NULL;
     12  t.balance = 0;
    1213}
    1314
    1415forall(otype K, otype V)
    15 void ^?{}(tree(K, V) * t){
    16   delete(t->left);
    17   delete(t->right);
    18   ^(&t->key){};
    19   ^(&t->value){};
     16void ^?{}(tree(K, V) & t){
     17  delete(t.left);
     18  delete(t.right);
     19  ^(t.key){};
     20  ^(t.value){};
    2021}
    2122
     
    2425  // infinite loop trying to resolve ... t = malloc();
    2526  tree(K, V) * t = malloc(sizeof(tree(K,V)));
    26   t { key, value };
     27  (*t){ key, value };
    2728  return t;
    2829}
  • src/tests/avltree/avl3.c

    r9f07232 rd3e4d6c  
    11#include "avl.h"
    22#include "avl-private.h"
     3#include <stdlib>
    34
    45// from stdlib
     
    3233  t->left = NULL;
    3334  t->right = NULL;
    34   deleteSingleNode(t);
     35  delete(t);
    3536}
    3637
  • src/tests/avltree/avl_test.c

    r9f07232 rd3e4d6c  
    11#include "avl.h"
    22#include "avl-private.h"
     3#include <stdlib>
    34
    45extern "C" {
Note: See TracChangeset for help on using the changeset viewer.