RegExp DEMO version --[4][regexp.h]核心数据类型(2)

作者在 2007-06-03 06:43:00 发布以下内容
/*##############################################*/
/*#######      *函数实现*     ######################*/
/*##############################################*/

/*状态*/
pState newState() {
      pState pS = NULL;
      pS = (pState)malloc(sizeof(State));
      if (pS != NULL) {
          pS->destStateCollection = newStateCollection();
          pS->next = NULL;
      }
      return pS;
}

void destroyState(pState s) {
      if (s != NULL) {
          destroyStateCollection(s->destStateCollection);
          free(s);
      }
}

pState setdestState(pState srcS, int eleindex, pState destS) {
      struct StateCollectionEletag *pSCEle;
      pSCEle = newStateCollectionEle(eleindex, destS);
      if (pSCEle != NULL) {
          appendStateCollection(srcS->destStateCollection, pSCEle);
      }
      return destS;
}

pState getdestState(pState srcS, int eleindex) {
      return NULL;
}

pState cloneState(pState s) {
      pState ps = NULL;
      ps = newState();
      if (ps != NULL) {
          ps->destStateCollection = cloneStateCollection(s->destStateCollection);
          ps->next = s->next;
      }
      return ps;
}

/*##############################################*/
/*状态集合元素*/
pStateCollectionEle newStateCollectionEle(int eleindex, pState destS) {
      pStateCollectionEle pSCEle = NULL;
      pSCEle = (pStateCollectionEle)malloc(sizeof(StateCollectionEle));
      if (pSCEle != NULL) {
          pSCEle->eleindex = eleindex;
          pSCEle->destState = destS;
          pSCEle->next = NULL;
      }
      return pSCEle;
}

void destroyStateCollectionEle(pStateCollectionEle pSCEle) {
      free(pSCEle);
}

pStateCollectionEle cloneStateCollectionEle(pStateCollectionEle pSCEle) {
      pStateCollectionEle psenew = NULL;
      psenew = newStateCollectionEle(pSCEle->eleindex, pSCEle->destState);
      if (psenew != NULL) {
          psenew->next = pSCEle->next;
      }
      return psenew;
}

/*##############################################*/
/*状态集合*/
pStateCollection newStateCollection() {
      pStateCollection pSC = NULL;
      pSC = (pStateCollection)malloc(sizeof(StateCollection));
      if (pSC != NULL) {
          pSC->destStateCount = 0;
          pSC->head = NULL;
      }
      return pSC;
}

void destroyStateCollection(pStateCollection pSC) {<
C语言 | 阅读 2109 次
文章评论,共0条
游客请输入验证码