Example #1
0
int
bmp_show_summary()
{
    char bs[32];
    char ms[32];
    char up[32];

    uptime_string(now.tv_sec - server.time.tv_sec, up, sizeof(up));

    dprintf(out, "\n");
    dprintf(out, "BMP Server (port %d)\n", server.port);
    dprintf(out, "  BMP Server pid     : %d\n", server.pid);
    dprintf(out, "  BMP Server uptime  : %s\n", up);
    dprintf(out, "  Active BGP routers : %d\n", avl_size(server.sessions));
    dprintf(out, "  Active BGP peers   : %d\n", 0);
    size_string(server.msgs, ms, sizeof(ms));
    dprintf(out, "  Total msgs rcv'd   : %s\n", ms);
    bytes_string(server.bytes, bs, sizeof(bs));
    dprintf(out, "  Total data rcv'd   : %s\n", bs);
    bytes_string(server.memory, bs, sizeof(bs));
    dprintf(out, "  Total memory usage : %s\n", bs);       

    dprintf(out, "\n");

    return 0;
}
static
Topform worst_clause(Picker p)
{
  /* If AGE_PICKER is not being used, simply return the last clause in P
     that does not match a hint.
     Otherwise, let A be the age (ID) of the median clause in AGE_PICKER;
     then return the last clause in P with ID > A that does not match a hint.
     (We don't delete old heavy clauses because they might be picked by
     AGE_PICKER.)
  */
  if (p == NULL || p->idx == NULL)
    return NULL;
  else {
    int median_id, n;
    Topform c;
    if (picker_empty(AGE_PICKER))
      median_id = 0;
    else {
      c = avl_item_at_position(Pickers[AGE_PICKER].idx, 0.5);
      median_id = c->id;
    }
    
    /* Start with largest, count down until ID > median_age && not hint matcher */
    n = avl_size(p->idx);
    c = avl_nth_item(p->idx, n);
    while (c && (c->id <= median_id || hint_matcher(c))) {
      c = avl_nth_item(p->idx, --n);
    }
    return c;
  }
}  /* worst_clause */
/* PUBLIC */
BOOL sos_keep1(Topform c, Clist sos, Prover_options opt)
{
  Plist pickers = pickers_for_clause(c);
  if (pickers == NULL)
    return FALSE;  /* no picker will accept the clause */
  else {
    int limit = parm(opt->sos_limit);
    /* printf("sos_keep, sos=%d, c=%d:", clist_length(sos), c->weight); */
    if (limit == -1) {
      zap_plist(pickers);
      return TRUE;  /* some picker wants the clause, and there is no limit */
    }
    else {
      double fullness_of_sos = clist_length(sos) / (double) limit;
      double x = .5;    /* when sos is at (x * limit), start being selective */
      if (fullness_of_sos < x) {
	zap_plist(pickers);
	return TRUE;  /* there is a limit, but we don't yet consider it */
      }
      else {
	Picker p;
	pickers = get_sos_limit_pickers(pickers);
	p = largest_picker(pickers);
	zap_plist(pickers);
	if (p == NULL) {
	  return FALSE;  /* all pickers complete, and we're getting full */
	}
	else {
	  /* keep if wt < than clause at ref_point */
	  double ref_point = x + (1 - fullness_of_sos);
	  /* fullness_of_sos >= x,
	     x <= ref_point <= 1.
	         if sos is full: ref_point=x
		 if sos is at x: ref_point=1
	   */
	  int n = avl_size(p->idx) * ref_point;
	  Topform d = avl_nth_item(p->idx, n);
	  if (d == NULL) {
	    return TRUE;  /* the picker is empty */
	  }
	  else {
	    if (c->weight >= d->weight) {
	      if (c->weight < p->low_delete) {
		printf("\nLow Water (keep, %s): wt=%d\n", p->name, c->weight);
		fflush(stdout);
		p->low_delete = c->weight;
	      }
	      p->number_deleted++;
	      return FALSE;
	    }
	    else {
	      /* keep the clause (smaller than clause at reference point) */
	      return TRUE;
	    }
	  }
	}
      }
    }
  }
}  /* sos_keep1 */
/* PUBLIC */
Topform get_given_clause1(Clist sos, int num_given,
			 Prover_options opt, char **type)
{
  if (clist_empty(sos))
    return NULL;
  else {
    Topform giv;

    if (flag(opt->input_sos_first) && initial_clause(sos->first->c)) {
      giv = sos->first->c;
      *type = "I";
    }
    else {
      int i = next_from_ratio();
      if (i < 0)
	return NULL;  /* something's probably wrong */
      else {
	Picker p = &(Pickers[i]);
	if (str_ident(p->name, "Random")) {
	  int n = avl_size(p->idx);
	  int i = (rand() % n) + 1;
	  giv = avl_nth_item(p->idx, i);
	}
	else
	  giv = avl_smallest(p->idx);
	*type = p->code;
      }
    }
    remove_from_sos1(giv, sos);
    return giv;
  }
}  /* get_given_clause1 */
Example #5
0
Py_LOCAL(PyObject *) avl_tree_pickle_dump(avl_tree_Object * self,
										  PyObject * pickler_object)
{
	if (!PyObject_HasAttrString(pickler_object, "dump")) {
		PyErr_SetString(PyExc_AttributeError,
						"Couln't pickle avl_tree: missing 'dump' attr");
		return NULL;
	} else {
		PyObject *dump_method = NULL;
		PyObject *rv = NULL;
		avl_iterator iter;
		void *cur_item;

		dump_method = PyObject_GetAttrString(pickler_object, "dump");
		if (!PyCallable_Check(dump_method)) {
			PyErr_SetString(PyExc_TypeError,
							"Couln't pickle avl_tree: 'dump' attr must be callable");
			goto finally;
		}
		iter = avl_iterator_new(self->tree, AVL_ITERATOR_INI_PRE);
		if (iter == NULL) {
			PyErr_SetString(avlErrorObject,
							"Sorry, couldn't allocate native iterator");
			goto finally;
		}
		/* dump the objects count */
		rv = PyObject_CallFunction(dump_method, "O",
								   PyInt_FromLong(avl_size(self->tree)));
		if (rv == NULL);
		else
			rv = PyObject_CallFunction(dump_method, "O",
									   self->compare_func);
		while (1) {
			if (rv == NULL) {
				/* pass the exception on */
				break;
			}
			Py_DECREF(rv);
			cur_item = avl_iterator_next(iter);
			if (cur_item == NULL) {
				rv = Py_None;
				Py_INCREF(rv);
				break;
			}
			rv = PyObject_CallFunction(dump_method, "(O)",
									   objectAt(cur_item));
		}
		avl_iterator_kill(iter);
	  finally:
		Py_DECREF(dump_method);
		return rv;
	}
}
Example #6
0
Py_LOCAL(PyObject *) avl_tree_append(avl_tree_Object * self,
									 PyObject * val)
{
	int rv;
	rv = avl_ins_index((void *) val, avl_size(self->tree) + 1, self->tree);
	if (rv < 0) {
		PyErr_SetString(avlErrorObject, "Sorry, couldn't append item");
		return NULL;
	}
	Py_INCREF(Py_None);
	return Py_None;
}
static
Picker largest_picker(Plist pickers)
{
  Picker largest_picker = NULL;
  int size_of_largest_picker = -1;
  Plist a;
  for (a = pickers; a; a = a->next) {
    Picker p = a->v;
    int size = avl_size(p->idx);
    if (size > size_of_largest_picker) {
      largest_picker = p;
      size_of_largest_picker = size;
    }
  }
  return largest_picker;
}  /* largest_picker */
Example #8
0
Py_LOCAL(PyObject *) avl_tree_repr(avl_tree_Object * self)
{
	PyObject *result = NULL;
	avl_size_t len;
	int rc;

	len = avl_size(self->tree);

	rc = Py_ReprEnter((PyObject *) self);
	if (rc != 0)
		return rc > 0 ? PyString_FromString("[...]") : NULL;

	if (len == 0) {
		result = PyString_FromString("[]");
		goto finish;
	}

	{
		avl_iterator iter;
		PyObject *list, *ob;
		Py_ssize_t i = 0;

		iter = avl_iterator_new(self->tree, AVL_ITERATOR_INI_PRE);
		if (iter == NULL)
			goto finish;

		list = PyList_New(len);
		if (list == NULL)
			goto finish;

		do {
			ob = objectAt(avl_iterator_next(iter));
			Py_INCREF(ob);
			PyList_SET_ITEM(list, i, ob);
			++i;
		} while (--len);

		avl_iterator_kill(iter);

		result = PyObject_Repr(list);
		list->ob_type->tp_dealloc(list);
	}

  finish:
	Py_ReprLeave((PyObject *) self);
	return result;
}
void comp_routine_release()
{
    int i;
    int count = avl_size(g_connections_map);
    SOCKET* array = (SOCKET*)malloc(count * sizeof(int));
    avl_serialize(g_connections_map, (avl_key_t*)array, count);
    for (i = 0; i < count; ++i)
    {
        socket_data_t* data = (socket_data_t*)avl_find(g_connections_map, array[i]);
        if (data)
        {
            free_data(data);
            avl_delete(g_connections_map, array[i]);
        }
    }
    free(array);
    avl_destroy_tree(g_connections_map);
    WSACleanup();
}
/* PUBLIC */
void picker_report(void)
{
  int i;
  print_separator(stdout, "PICKER REPORT", TRUE);
  printf("%16s  %6s  %10s  %8s  %6s  %11s  %6s\n",
	 "Picker","Size","Median_wt","Deleted","(Low)","Displaced","(Low)");
  for (i = 0; i < NUM_PICKERS; i++) {
    Picker p = &(Pickers[i]);
    Topform c = avl_item_at_position(p->idx, 0.5);
    printf("%16s  %6d  %10d  %8d  %6d  %11d  %6d\n",
	   p->name, avl_size(p->idx), c ? c->weight : -1,
	   p->number_deleted,
	   p->low_delete == INT_MAX ? -1 : p->low_delete,
	   p->number_displaced,
	   p->low_displace == INT_MAX ? -1 : p->low_displace);
  }
  print_separator(stdout, "end of picker report", FALSE);
  fflush(stdout);
}  /* picker_report */
Example #11
0
Py_LOCAL(PyObject *) avl_tree_slice(avl_tree_Object * self, Py_ssize_t lo,
									Py_ssize_t hi)
{
	avl_tree_Object *rv;
	avl_size_t len;

	rv = PyObject_NEW(avl_tree_Object, &avl_tree_Type);
	if (rv == NULL)
		return NULL;

	len = avl_size(self->tree);

	if (lo < 0 && (lo += len) < 0)
		lo = 0;
	if (hi < 0 && (hi += len) < 0)
		hi = 0;
	if (lo >= hi) {
		lo = hi = 0;
	} else if (hi > len) {
		hi = len;
	}

	if (len == hi - lo)
		rv->tree = avl_dup(self->tree, (void *) rv);
	else
		rv->tree =
			avl_slice(self->tree, (avl_size_t) (lo + 1),
					  (avl_size_t) (hi + 1), (void *) rv);

	if (rv->tree == NULL) {
		PyErr_SetString(avlErrorObject, "Couldn't build slice");
		PyObject_DEL(rv);
		return NULL;
	}

	rv->compare_func = self->compare_func;
	Py_INCREF(rv->compare_func);

	return (PyObject *) rv;
}
Example #12
0
Py_LOCAL(PyObject *) avl_tree_ins(avl_tree_Object * self, PyObject * args)
{
	PyObject *arg1, *arg2 = NULL;
	avl_code_t rv;

	if (!PyArg_ParseTuple(args, "O|O:insert", &arg1, &arg2))
		return NULL;

	if (arg2 == NULL) {
		rv = avl_ins((void *) arg1, self->tree, avl_true);
		/* compare failed and insertion was prevented */
		if (rv == -2)
			return NULL;
	} else if (PyInt_Check(arg2) || PyLong_Check(arg2)) {
		long idx = PyInt_AsLong(arg2);	/*PyInt_AsUnsignedLongMask(arg2) */
		avl_size_t rank;

		if (idx < 0)
			rank = idx + avl_size(self->tree);
		else
			rank = idx;

		if ((rv = avl_ins_index((void *) arg1, rank + 1, self->tree)) == 0) {
			PyErr_SetString(PyExc_IndexError,
							"insertion index out of range");
			return NULL;
		}
	} else {
		PyErr_SetString(PyExc_TypeError,
						"insertion index expected (argument 2)");
		return NULL;
	}

	if (rv < 0) {
		PyErr_SetString(avlErrorObject, "Sorry, couldn't insert item");
		return NULL;
	}
	Py_INCREF(Py_None);
	return Py_None;
}
Example #13
0
Py_LOCAL(PyObject *) avl_tree_rem_index(avl_tree_Object * self,
										PyObject * args)
{
	int idx = -1;

	if (PyArg_ParseTuple(args, "i:rem_index", &idx)) {
		avl_size_t rank;

		if (idx < 0)
			rank = idx + avl_size(self->tree);
		else
			rank = idx;

		if (avl_del_index(rank + 1, self->tree, NULL) == 0) {
			PyErr_SetString(PyExc_IndexError,
							"avl_tree removal index out of range");
			return NULL;
		}

		Py_INCREF(Py_None);
		return Py_None;
	}
	return NULL;
}
Example #14
0
int
main (int argc, char ** argv)
{
  avl_t avl;
  size_t size, i;
  void ** tmp;

  /* Default Constructor */
  avl = avl_init_free (compare, free_int);
  if (avl == NULL)
    return 99;

  /* Test Empty Size */
  if (avl_size (avl) != 0)
    {
      printf ("Invalid Initial Size\n");
      return EXIT_FAILURE;
    }

  /* Test get, remove, and replace on empty */
  if (avl_replace (avl, (void *)1, (void *)1) != AVL_KEY_INVALID)
    {
      printf ("Empty AVL Replace Invalid Key\n");
      return EXIT_FAILURE;
    }
  if (avl_get (avl, (void *)1) != NULL)
    {
      printf ("Empty AVL Get Invalid Key\n");
      return EXIT_FAILURE;
    }
  if (avl_remove (avl, (void *)1) != AVL_KEY_INVALID)
    {
      printf ("Empty AVL Remove Invalid Key\n");
      return EXIT_FAILURE;
    }

  /* Test 3 inserts */
  if (avl_insert (avl, (void *)0, (void *)0) == AVL_MALLOC_FAILED ||
      avl_insert (avl, (void *)1, (void *)3) == AVL_MALLOC_FAILED ||
      avl_insert (avl, (void *)2, (void *)2) == AVL_MALLOC_FAILED)
    return 99;
  if (avl_size (avl) != 3)
    {
      printf ("Three Inserts Size Failed\n");
      return EXIT_FAILURE;
    }
  if (avl_get (avl, (void *)0) != (void *)0 ||
      avl_get (avl, (void *)2) != (void *)2 ||
      avl_get (avl, (void *)1) != (void *)3)
    {
      printf ("Three Inserts Failed\n");
      return EXIT_FAILURE;
    }

  /* Test replace and insert_replace */
  if (avl_insert_rep (avl, (void *)3, (void *)10) != AVL_OK ||
      avl_replace (avl, (void *)3, (void *)3) != AVL_OK ||
      avl_insert_rep (avl, (void *)1, (void *)1) != AVL_OK)
    {
      printf ("Replaces and inserts failed\n");
      return EXIT_FAILURE;
    }
  if (avl_size (avl) != 4)
    {
      printf ("Replace and Inserts Size Failed\n");
      return EXIT_FAILURE;
    }
  if (avl_get (avl, (void *)0) != (void *)0 ||
      avl_get (avl, (void *)1) != (void *)1 ||
      avl_get (avl, (void *)2) != (void *)2 ||
      avl_get (avl, (void *)3) != (void *)3)
    {
      printf ("Replace and Inserts Failed\n");
      return EXIT_FAILURE;
    }

  /* Test Failed Insert and Failed Replace */
  if (avl_insert (avl, (void *)1, (void *)4) != AVL_KEY_EXISTS ||
      avl_replace (avl, (void *)10, (void *)1) != AVL_KEY_INVALID)
    {
      printf ("Passed when insert / replace it should fail\n");
      return EXIT_FAILURE;
    }
  if (avl_size (avl) != 4)
    {
      printf ("Invalid insert / replace Size Failed\n");
      return EXIT_FAILURE;
    }
  if (avl_get (avl, (void *)0) != (void *)0 ||
      avl_get (avl, (void *)1) != (void *)1 ||
      avl_get (avl, (void *)2) != (void *)2 ||
      avl_get (avl, (void *)3) != (void *)3)
    {
      printf ("Invalid insert / replace Failed\n");
      return EXIT_FAILURE;
    }

  /* Test Clear */
  avl_clear (avl);
  if (avl_size (avl) != 0 ||
      avl_get (avl, (void *)1) != NULL)
    {
      printf ("Clearing the AVL Failed\n");
      return EXIT_FAILURE;
    }

  /* Test Many Inserts */
  size = 1000;
  for (i = 0; i < size; i++)
    avl_insert (avl, (void *)i, (void *)i);
  if (avl_size (avl) != size)
    {
      printf ("Many Inserts Size Failed\n");
      return EXIT_FAILURE;;
    }
  for (i = 0; i < size; i++)
    if (avl_get (avl, (void *)i) != (void *)i)
      {
	printf ("Many Inserts Failed\n");
	return EXIT_FAILURE;
      }

  /* Default Destructor */
  avl_destroy (avl);

  /* Test more complex free routine */
  avl = avl_init_free (compare, free_complex);
  tmp = (void **) malloc (sizeof (void *));
  *tmp = malloc (16);
  avl_insert (avl, tmp, NULL);
  avl_destroy (avl);

  return EXIT_SUCCESS;;
}
Example #15
0
Py_LOCAL(Py_ssize_t) avl_tree_size(avl_tree_Object * self)
{
	return (Py_ssize_t) avl_size(self->tree);
}
Example #16
0
int main(int argc, char *argv[]) 
{
    avl_tree *ptree;
    avl_tree *itree;
    avl_tree *mtree;

    avl_node *lookup = (avl_node*)0x1;
    struct timeval start, finish;
    int i, x;



    printf("\nP-TREE:\n");

    for (i = 0; i < NNN; i++) ndata[i] = i;
    for (i = 0; i < MMM; i++) mdata[i] = i;
   
    ptree = avl_init(int_compare, NULL, 0);

    gettimeofday(&start, NULL);
    for (i = 0; i < MMM; i++) avl_insert(ptree, &mdata[i], NULL);
    //for (i = NNN; i > 0; i--) avl_insert(ptree, &ndata[i], NULL); 
    gettimeofday(&finish, NULL);
    printf("INSERT: n = %7d h = %2d v = %d (%d sec %u msec)\n", avl_size(ptree), 
                                                                avl_height(ptree), 
                                                                avl_validate(ptree, ptree->root, NULL),
                                                                (int)         (finish.tv_sec  - start.tv_sec ), 
                                                                (unsigned int)(finish.tv_usec - start.tv_usec)/1000);

    gettimeofday(&start, NULL);
    for (i = 0; i < MMM && lookup; i++) lookup = avl_lookup(ptree, &mdata[i], NULL);
    gettimeofday(&finish, NULL);
    printf("LOOKUP: n = %7d h = %2d v = %d (%d sec %u msec)\n", i, 
                                                                avl_height(ptree), 
                                                                avl_validate(ptree, ptree->root, NULL),
                                                                (int)         (finish.tv_sec  - start.tv_sec ), 
                                                                (unsigned int)(finish.tv_usec - start.tv_usec)/1000);

    gettimeofday(&start, NULL);

    for (i = NNN - 1; i >= 0; i--) { 
        avl_remove(ptree, &ndata[i], NULL);
    }

#if 0
    for (i = 0, srand(time(NULL)); i < NNN;) {
        x = rand() % NNN;
        if (avl_lookup(ptree, &ndata[x], NULL)) {
            avl_remove(ptree, &ndata[x], NULL);
            assert(avl_validate(ptree, ptree->root, NULL));
            i++;
        }
    }
#endif

    gettimeofday(&finish, NULL);
    printf("REMOVE: n = %7d h = %2d v = %d (%d sec %u msec)\n", avl_size(ptree),
                                                                avl_height(ptree),
                                                                avl_validate(ptree, ptree->root, NULL),
                                                                (int)         (finish.tv_sec  - start.tv_sec ), 
                                                                (unsigned int)(finish.tv_usec - start.tv_usec)/1000);

    gettimeofday(&start, NULL);
    avl_free(ptree);
    gettimeofday(&finish, NULL);
    printf("DSTROY: n = %7d h = %2d v = %d (%d sec  %u msec)\n", 0, 
                                                                 0,
                                                                 1,
                                                                 (int)         (finish.tv_sec  - start.tv_sec ),
                                                                 (unsigned int)(finish.tv_usec - start.tv_usec)/1000); 
   

    printf("\nI-TREE:\n");

    memset(nintr, 0, NNN * sizeof(intr));
    memset(mintr, 0, MMM * sizeof(intr));
    for (i = 0; i < NNN; i++) nintr[i].data = i;
    for (i = 0; i < MMM; i++) mintr[i].data = i;

    itree = avl_init(intr_compare, NULL, AVL_TREE_INTRUSIVE);


    gettimeofday(&start, NULL);
    for (i = 0; i < MMM; i++) avl_insert(itree, &mintr[i], NULL);
    //for (i = NNN - 1; i >= 0; i--) avl_insert(itree, &nintr[i], NULL); 
    gettimeofday(&finish, NULL);
    printf("INSERT: n = %7d h = %2d v = %d (%d sec %u msec)\n", avl_size(itree), 
                                                                avl_height(itree),
                                                                avl_validate(itree, itree->root, NULL),
                                                                (int)         (finish.tv_sec  - start.tv_sec ), 
                                                                (unsigned int)(finish.tv_usec - start.tv_usec)/1000);

    gettimeofday(&start, NULL);
    for (i = 0; i < MMM && lookup; i++) lookup = avl_lookup(itree, &mintr[i], NULL);
    gettimeofday(&finish, NULL);
    printf("LOOKUP: n = %7d h = %2d v = %d (%d sec %u msec)\n", i, 
                                                                avl_height(itree), 
                                                                avl_validate(itree, itree->root, NULL),
                                                                (int)         (finish.tv_sec  - start.tv_sec ), 
                                                                (unsigned int)(finish.tv_usec - start.tv_usec)/1000);

    gettimeofday(&start, NULL);

   
    for (i = NNN - 1; i >= 0; i--) { 
        avl_remove(itree, &nintr[i], NULL);
    }

#if 0
    for (i = 0, srand(time(NULL)); i < NNN;) {
        x = rand() % NNN;
        if (avl_lookup(itree, &nintr[x], NULL)) {
            avl_remove(itree, &nintr[x], NULL);
            assert(avl_validate(itree, itree->root, NULL));
            i++;
        }
    }
#endif

    gettimeofday(&finish, NULL);
    printf("REMOVE: n = %7d h = %2d v = %d (%d sec %u msec)\n", avl_size(itree),
                                                                avl_height(itree),
                                                                avl_validate(itree, itree->root, NULL),
                                                                (int)         (finish.tv_sec  - start.tv_sec ), 
                                                                (unsigned int)(finish.tv_usec - start.tv_usec)/1000);


    gettimeofday(&start, NULL);
    avl_free(itree);
    gettimeofday(&finish, NULL);
    printf("DSTROY: n = %7d h = %2d v = %d (%d sec  %u msec)\n\n", 0, 
                                                                   0,
                                                                   1,
                                                                   (int)         (finish.tv_sec  - start.tv_sec ),
                                                                   (unsigned int)(finish.tv_usec - start.tv_usec)/1000); 




    printf("\nM-TREE:\n");

    memset(nmulti, 0, NNN * sizeof(multi));
    memset(mmulti, 0, MMM * sizeof(multi));
    for (i = 0; i < NNN; i++) {nmulti[i].key[0] = i;nmulti[i].key[1] = i+1;}
    for (i = 0; i < MMM; i++) {mmulti[i].key[0] = i;mmulti[i].key[1] = i+1;}


    avl_compare_fn comps[2] = { multi_comp_0, multi_comp_1 };

    mtree = avl_multi_init(comps, NULL, 2, AVL_TREE_INTRUSIVE);


    gettimeofday(&start, NULL);
    for (i = 0; i < MMM; i++) avl_multi_insert(mtree, &mmulti[i], NULL);
    //for (i = NNN - 1; i >= 0; i--) avl_multi_insert(mtree, &nmulti[i], NULL); 
    gettimeofday(&finish, NULL);
    printf("INSERT: n = %7d h = %2d v = %d (%d sec %u msec)\n", avl_size(mtree), 
                                                                avl_height(mtree),
                                                                avl_validate(mtree, mtree->root, NULL) &&
                                                                avl_validate(&mtree[0], mtree[0].root, NULL) ==
                                                                avl_validate(&mtree[1], mtree[1].root, NULL) ,
                                                                (int)         (finish.tv_sec  - start.tv_sec ), 
                                                                (unsigned int)(finish.tv_usec - start.tv_usec)/1000);

    gettimeofday(&start, NULL);
    for (i = 0; i < MMM && lookup; i++) lookup = avl_lookup(mtree, &mmulti[i], NULL);
    gettimeofday(&finish, NULL);
    printf("LOOKUP: n = %7d h = %2d v = %d (%d sec %u msec)\n", avl_size(mtree), 
                                                                avl_height(mtree),
                                                                avl_validate(mtree, mtree->root, NULL) &&
                                                                avl_validate(&mtree[0], mtree[0].root, NULL) ==
                                                                avl_validate(&mtree[1], mtree[1].root, NULL) ,
                                                                (int)         (finish.tv_sec  - start.tv_sec ), 
                                                                (unsigned int)(finish.tv_usec - start.tv_usec)/1000);

    gettimeofday(&start, NULL);


    //avl_walk(&mtree[0], multi_print_0, NULL, 0); printf("---\n");fflush(stdout);
    //avl_walk(&mtree[1], multi_print_1, NULL, 0); printf("===\n");fflush(stdout);

   
    for (i = MMM - 1; i >= 1000; i--) { 
        avl_multi_remove(mtree, &mmulti[i], NULL);
    }

    //avl_walk(&mtree[0], multi_print_0, NULL, 0); printf("---\n");fflush(stdout);
    //avl_walk(&mtree[1], multi_print_1, NULL, 0); printf("===\n");fflush(stdout);

#if 0
    for (i = 0, srand(time(NULL)); i < NNN;) {
        x = rand() % NNN;
        if (avl_lookup(itree, &nintr[x], NULL)) {
            avl_remove(itree, &nintr[x], NULL);
            assert(avl_validate(itree, itree->root, NULL));
            i++;
        }
    }
#endif

    gettimeofday(&finish, NULL);
    printf("REMOVE: n = %7d h = %2d v = %d (%d sec %u msec)\n", avl_size(mtree), 
                                                                avl_height(mtree),
                                                                avl_validate(mtree, mtree->root, NULL) &&
                                                                avl_validate(&mtree[0], mtree[0].root, NULL) ==
                                                                avl_validate(&mtree[1], mtree[1].root, NULL) ,
                                                                (int)         (finish.tv_sec  - start.tv_sec ), 
                                                                (unsigned int)(finish.tv_usec - start.tv_usec)/1000);


    gettimeofday(&start, NULL);
    avl_free(mtree);
    gettimeofday(&finish, NULL);
    printf("DSTROY: n = %7d h = %2d v = %d (%d sec  %u msec)\n\n", 0, 
                                                                   0,
                                                                   1,
                                                                   (int)         (finish.tv_sec  - start.tv_sec ),
                                                                   (unsigned int)(finish.tv_usec - start.tv_usec)/1000); 

  

    return 0;
}