/misc/src/release/graphviz-2.18-1/src/graphviz-2.18/lib/cdt/dtsize.c

Go to the documentation of this file.
00001 /* $Id: dtsize.c,v 1.1.1.1 2004/12/23 04:04:01 ellson Exp $ $Revision: 1.1.1.1 $ */
00002 /* vim:set shiftwidth=4 ts=8: */
00003 
00004 /**********************************************************
00005 *      This software is part of the graphviz package      *
00006 *                http://www.graphviz.org/                 *
00007 *                                                         *
00008 *            Copyright (c) 1994-2004 AT&T Corp.           *
00009 *                and is licensed under the                *
00010 *            Common Public License, Version 1.0           *
00011 *                      by AT&T Corp.                      *
00012 *                                                         *
00013 *        Information and Software Systems Research        *
00014 *              AT&T Research, Florham Park NJ             *
00015 **********************************************************/
00016 
00017 #include        "dthdr.h"
00018 
00019 #ifdef DMALLOC
00020 #include "dmalloc.h"
00021 #endif
00022 
00023 /*      Return the # of objects in the dictionary
00024 **
00025 **      Written by Kiem-Phong Vo (5/25/96)
00026 */
00027 
00028 #if __STD_C
00029 static int treecount(reg Dtlink_t * e)
00030 #else
00031 static int treecount(e)
00032 reg Dtlink_t *e;
00033 #endif
00034 {
00035     return e ? treecount(e->left) + treecount(e->right) + 1 : 0;
00036 }
00037 
00038 #if __STD_C
00039 int dtsize(Dt_t * dt)
00040 #else
00041 int dtsize(dt)
00042 Dt_t *dt;
00043 #endif
00044 {
00045     reg Dtlink_t *t;
00046     reg int size;
00047 
00048     UNFLATTEN(dt);
00049 
00050     if (dt->data->size < 0) {   /* !(dt->data->type&(DT_SET|DT_BAG)) */
00051         if (dt->data->type & (DT_OSET | DT_OBAG))
00052             dt->data->size = treecount(dt->data->here);
00053         else if (dt->data->type & (DT_LIST | DT_STACK | DT_QUEUE)) {
00054             for (size = 0, t = dt->data->head; t; t = t->right)
00055                 size += 1;
00056             dt->data->size = size;
00057         }
00058     }
00059 
00060     return dt->data->size;
00061 }

Generated on Mon Mar 31 19:03:23 2008 for Graphviz by  doxygen 1.5.1