⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 n_dim_traversal.c~

📁 混沌分析工具
💻 C~
字号:
#include<stdio.h>#include<malloc.h>#include<varargs.h>#include "n_dim_traversal.h"/* Note: VALTYPE and VALNULL are defined in n_dim_traversal.h */int dimsize=500;void insert_val (LEAFTYPE *, VALTYPE);void insert_val(locn, val)     LEAFTYPE *locn;     VALTYPE val;{  if (*locn == NULL) {    if ((*locn = (LEAFTYPE)malloc(sizeof(LEAFTYPE))) == NULL) {      fprintf(stderr, "Cannot allocate memory for list entry\n");      exit(-1);    }    (*locn)->val = val;    (*locn)->next = (LEAFTYPE) NULL;  } else {    insert_val(&((*locn)->next), val);  }}void enter_value(VALTYPE, void **, int, int *);void enter_value(val, list, dims, x)      VALTYPE val;      void **list;      int dims;      int *x;{  int i;  if (*list == NULL) {    if ((*list = (void *)malloc(sizeof(LEAFTYPE)*dimsize)) == NULL) {      fprintf(stderr, "Cannot allocate memory!\n");      exit(-1);    }    if (dims==1) {      for (i=0; i<dimsize; i++) {        ((LEAFTYPE *) (*list))[i] = VALNULL;      }    } else {      for (i=0; i<dimsize; i++) {        ((void **) (*list))[i] = (void *) 0;      }    }  }  if ((x[0] < 0) || (x[0] > dimsize)) {    fprintf(stderr, "Coordinate entry %d is not between 0 and %d\n", x[0], dimsize);    exit(-1);  }  if (dims==1) {    /* This is where the entry is updated.  For linked lists, more */    /* code will be required to handle the insertion.  (Probably */    /* best done by a function call I would think). */    insert_val(&(((LEAFTYPE *) (*list))[x[0]]), val);  } else {    enter_value(val, &(((void **) (*list))[x[0]]), dims-1, &(x[1]));  }}#if 0LEAFTYPE _get_value(void **, int, va_list);LEAFTYPE _get_value(list, dims, ap)      void **list;      int dims;      va_list ap;{  int coord;  if (*list == NULL) {    return((LEAFTYPE) 0);  }  coord = va_arg(ap, int);  if ((coord < 0) || (coord > dimsize)) {    fprintf(stderr, "Coordinate entry %d is not between 0 and %d\n", coord, dimsize);    exit(-1);  }  if (dims==1) {    /* This is where the actual value is returned.  Some further work */    /* would be required in here to manipulate lists */    return(((LEAFTYPE *) (*list))[coord]);  } else {    return(_get_value(&(((void **) (*list))[coord]), dims-1, ap));  }}LEAFTYPE get_value(list, dims, va_alist)      void **list;      int dims;      va_dcl{  va_list ap;  LEAFTYPE value;  va_start(ap);  value = _get_value(list, dims, ap);  va_end(ap);  return(value);}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -