00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "gspin-tree.h"
00025 #include "gspin-list.h"
00026
00027 gs_count_t gs_length (gs_t list)
00028 {
00029 GS_ASSERT (list != (gs_t) NULL, "got null list.");
00030 int n;
00031 for (n=0;gs_code(list) != EMPTY; n++, list = gs_operand(list, 1));
00032 return n;
00033 }
00034
00035 gs_t gs_index (gs_t list, gs_count_t index)
00036 {
00037 GS_ASSERT (list != (gs_t) NULL, "got null list.");
00038 GS_ASSERT (gs_length(list) > index, "index >= length of list too large.");
00039
00040 for (; index != 0; index--, list = gs_operand(list, 1));
00041 return gs_operand(list, 0);
00042 }
00043
00044 #ifdef FE_GNU_4_2_0
00045 void gs_set_index (gs_t list, gs_count_t index, gs_t value)
00046 {
00047 GS_ASSERT (list != (gs_t) NULL, "got null list.");
00048 GS_ASSERT (gs_length(list) > index, "index >= length of list too large.");
00049
00050 for (; index != 0; index--, list = gs_operand(list, 1));
00051 gs_set_operand(list, 0, value);
00052 }
00053 #endif