亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? btree_rb.c

?? sqlite源碼wince移植版
?? C
?? 第 1 頁 / 共 3 頁
字號:
/* * A child of pParent, which in turn had child pX, has just been removed from  * pTree (the figure below depicts the operation, Z is being removed). pParent * or pX, or both may be NULL.   *                |           | *                P           P *               / \         / \ *              Z           X *             / \ *            X  nil * * This function is only called if Z was black. In this case the red-black tree * properties have been violated, and pX has an "extra black". This function  * performs rotations and color-changes to re-balance the tree. */static void do_delete_balancing(BtRbTree *pTree, BtRbNode *pX, BtRbNode *pParent){  BtRbNode *pSib;   /* TODO: Comment this code! */  while( pX != pTree->pHead && (!pX || pX->isBlack) ){    if( pX == pParent->pLeft ){      pSib = pParent->pRight;      if( pSib && !(pSib->isBlack) ){        pSib->isBlack = 1;        pParent->isBlack = 0;        leftRotate(pTree, pParent);        pSib = pParent->pRight;      }      if( !pSib ){        pX = pParent;      }else if(           (!pSib->pLeft  || pSib->pLeft->isBlack) &&          (!pSib->pRight || pSib->pRight->isBlack) ) {        pSib->isBlack = 0;        pX = pParent;      }else{        if( (!pSib->pRight || pSib->pRight->isBlack) ){          if( pSib->pLeft ) pSib->pLeft->isBlack = 1;          pSib->isBlack = 0;          rightRotate( pTree, pSib );          pSib = pParent->pRight;        }        pSib->isBlack = pParent->isBlack;        pParent->isBlack = 1;        if( pSib->pRight ) pSib->pRight->isBlack = 1;        leftRotate(pTree, pParent);        pX = pTree->pHead;      }    }else{      pSib = pParent->pLeft;      if( pSib && !(pSib->isBlack) ){        pSib->isBlack = 1;        pParent->isBlack = 0;        rightRotate(pTree, pParent);        pSib = pParent->pLeft;      }      if( !pSib ){        pX = pParent;      }else if(           (!pSib->pLeft  || pSib->pLeft->isBlack) &&          (!pSib->pRight || pSib->pRight->isBlack) ){        pSib->isBlack = 0;        pX = pParent;      }else{        if( (!pSib->pLeft || pSib->pLeft->isBlack) ){          if( pSib->pRight ) pSib->pRight->isBlack = 1;          pSib->isBlack = 0;          leftRotate( pTree, pSib );          pSib = pParent->pLeft;        }        pSib->isBlack = pParent->isBlack;        pParent->isBlack = 1;        if( pSib->pLeft ) pSib->pLeft->isBlack = 1;        rightRotate(pTree, pParent);        pX = pTree->pHead;      }    }    pParent = pX->pParent;  }  if( pX ) pX->isBlack = 1;}/* * Create table n in tree pRbtree. Table n must not exist. */static void btreeCreateTable(Rbtree* pRbtree, int n){  BtRbTree *pNewTbl = sqliteMalloc(sizeof(BtRbTree));  sqliteHashInsert(&pRbtree->tblHash, 0, n, pNewTbl);}/* * Log a single "rollback-op" for the given Rbtree. See comments for struct * BtRollbackOp. */static void btreeLogRollbackOp(Rbtree* pRbtree, BtRollbackOp *pRollbackOp){  assert( pRbtree->eTransState == TRANS_INCHECKPOINT ||      pRbtree->eTransState == TRANS_INTRANSACTION );  if( pRbtree->eTransState == TRANS_INTRANSACTION ){    pRollbackOp->pNext = pRbtree->pTransRollback;    pRbtree->pTransRollback = pRollbackOp;  }  if( pRbtree->eTransState == TRANS_INCHECKPOINT ){    if( !pRbtree->pCheckRollback ){      pRbtree->pCheckRollbackTail = pRollbackOp;    }    pRollbackOp->pNext = pRbtree->pCheckRollback;    pRbtree->pCheckRollback = pRollbackOp;  }}int sqliteRbtreeOpen(  const char *zFilename,  int mode,  int nPg,  Btree **ppBtree){  Rbtree **ppRbtree = (Rbtree**)ppBtree;  *ppRbtree = (Rbtree *)sqliteMalloc(sizeof(Rbtree));  if( sqlite_malloc_failed ) goto open_no_mem;  sqliteHashInit(&(*ppRbtree)->tblHash, SQLITE_HASH_INT, 0);  /* Create a binary tree for the SQLITE_MASTER table at location 2 */  btreeCreateTable(*ppRbtree, 2);  if( sqlite_malloc_failed ) goto open_no_mem;  (*ppRbtree)->next_idx = 3;  (*ppRbtree)->pOps = &sqliteRbtreeOps;  /* Set file type to 4; this is so that "attach ':memory:' as ...."  does not  ** think that the database in uninitialised and refuse to attach  */  (*ppRbtree)->aMetaData[2] = 4;    return SQLITE_OK;open_no_mem:  *ppBtree = 0;  return SQLITE_NOMEM;}/* * Create a new table in the supplied Rbtree. Set *n to the new table number. * Return SQLITE_OK if the operation is a success. */static int memRbtreeCreateTable(Rbtree* tree, int* n){  assert( tree->eTransState != TRANS_NONE );  *n = tree->next_idx++;  btreeCreateTable(tree, *n);  if( sqlite_malloc_failed ) return SQLITE_NOMEM;  /* Set up the rollback structure (if we are not doing this as part of a   * rollback) */  if( tree->eTransState != TRANS_ROLLBACK ){    BtRollbackOp *pRollbackOp = sqliteMalloc(sizeof(BtRollbackOp));    if( pRollbackOp==0 ) return SQLITE_NOMEM;    pRollbackOp->eOp = ROLLBACK_DROP;    pRollbackOp->iTab = *n;    btreeLogRollbackOp(tree, pRollbackOp);  }  return SQLITE_OK;}/* * Delete table n from the supplied Rbtree.  */static int memRbtreeDropTable(Rbtree* tree, int n){  BtRbTree *pTree;  assert( tree->eTransState != TRANS_NONE );  memRbtreeClearTable(tree, n);  pTree = sqliteHashInsert(&tree->tblHash, 0, n, 0);  assert(pTree);  assert( pTree->pCursors==0 );  sqliteFree(pTree);  if( tree->eTransState != TRANS_ROLLBACK ){    BtRollbackOp *pRollbackOp = sqliteMalloc(sizeof(BtRollbackOp));    if( pRollbackOp==0 ) return SQLITE_NOMEM;    pRollbackOp->eOp = ROLLBACK_CREATE;    pRollbackOp->iTab = n;    btreeLogRollbackOp(tree, pRollbackOp);  }  return SQLITE_OK;}static int memRbtreeKeyCompare(RbtCursor* pCur, const void *pKey, int nKey,                                 int nIgnore, int *pRes){  assert(pCur);  if( !pCur->pNode ) {    *pRes = -1;  } else {    if( (pCur->pNode->nKey - nIgnore) < 0 ){      *pRes = -1;    }else{      *pRes = key_compare(pCur->pNode->pKey, pCur->pNode->nKey-nIgnore,           pKey, nKey);    }  }  return SQLITE_OK;}/* * Get a new cursor for table iTable of the supplied Rbtree. The wrFlag * parameter indicates that the cursor is open for writing. * * Note that RbtCursor.eSkip and RbtCursor.pNode both initialize to 0. */static int memRbtreeCursor(  Rbtree* tree,  int iTable,  int wrFlag,  RbtCursor **ppCur){  RbtCursor *pCur;  assert(tree);  pCur = *ppCur = sqliteMalloc(sizeof(RbtCursor));  if( sqlite_malloc_failed ) return SQLITE_NOMEM;  pCur->pTree  = sqliteHashFind(&tree->tblHash, 0, iTable);  assert( pCur->pTree );  pCur->pRbtree = tree;  pCur->iTree  = iTable;  pCur->pOps = &sqliteRbtreeCursorOps;  pCur->wrFlag = wrFlag;  pCur->pShared = pCur->pTree->pCursors;  pCur->pTree->pCursors = pCur;  assert( (*ppCur)->pTree );  return SQLITE_OK;}/* * Insert a new record into the Rbtree.  The key is given by (pKey,nKey) * and the data is given by (pData,nData).  The cursor is used only to * define what database the record should be inserted into.  The cursor * is left pointing at the new record. * * If the key exists already in the tree, just replace the data.  */static int memRbtreeInsert(  RbtCursor* pCur,  const void *pKey,  int nKey,  const void *pDataInput,  int nData){  void * pData;  int match;  /* It is illegal to call sqliteRbtreeInsert() if we are  ** not in a transaction */  assert( pCur->pRbtree->eTransState != TRANS_NONE );  /* Make sure some other cursor isn't trying to read this same table */  if( checkReadLocks(pCur) ){    return SQLITE_LOCKED; /* The table pCur points to has a read lock */  }  /* Take a copy of the input data now, in case we need it for the    * replace case */  pData = sqliteMallocRaw(nData);  if( sqlite_malloc_failed ) return SQLITE_NOMEM;  memcpy(pData, pDataInput, nData);  /* Move the cursor to a node near the key to be inserted. If the key already   * exists in the table, then (match == 0). In this case we can just replace   * the data associated with the entry, we don't need to manipulate the tree.   *    * If there is no exact match, then the cursor points at what would be either   * the predecessor (match == -1) or successor (match == 1) of the   * searched-for key, were it to be inserted. The new node becomes a child of   * this node.   *    * The new node is initially red.   */  memRbtreeMoveto( pCur, pKey, nKey, &match);  if( match ){    BtRbNode *pNode = sqliteMalloc(sizeof(BtRbNode));    if( pNode==0 ) return SQLITE_NOMEM;    pNode->nKey = nKey;    pNode->pKey = sqliteMallocRaw(nKey);    if( sqlite_malloc_failed ) return SQLITE_NOMEM;    memcpy(pNode->pKey, pKey, nKey);    pNode->nData = nData;    pNode->pData = pData;     if( pCur->pNode ){      switch( match ){        case -1:          assert( !pCur->pNode->pRight );          pNode->pParent = pCur->pNode;          pCur->pNode->pRight = pNode;          break;        case 1:          assert( !pCur->pNode->pLeft );          pNode->pParent = pCur->pNode;          pCur->pNode->pLeft = pNode;          break;        default:          assert(0);      }    }else{      pCur->pTree->pHead = pNode;    }    /* Point the cursor at the node just inserted, as per SQLite requirements */    pCur->pNode = pNode;    /* A new node has just been inserted, so run the balancing code */    do_insert_balancing(pCur->pTree, pNode);    /* Set up a rollback-op in case we have to roll this operation back */    if( pCur->pRbtree->eTransState != TRANS_ROLLBACK ){      BtRollbackOp *pOp = sqliteMalloc( sizeof(BtRollbackOp) );      if( pOp==0 ) return SQLITE_NOMEM;      pOp->eOp = ROLLBACK_DELETE;      pOp->iTab = pCur->iTree;      pOp->nKey = pNode->nKey;      pOp->pKey = sqliteMallocRaw( pOp->nKey );      if( sqlite_malloc_failed ) return SQLITE_NOMEM;      memcpy( pOp->pKey, pNode->pKey, pOp->nKey );      btreeLogRollbackOp(pCur->pRbtree, pOp);    }  }else{     /* No need to insert a new node in the tree, as the key already exists.     * Just clobber the current nodes data. */    /* Set up a rollback-op in case we have to roll this operation back */    if( pCur->pRbtree->eTransState != TRANS_ROLLBACK ){      BtRollbackOp *pOp = sqliteMalloc( sizeof(BtRollbackOp) );      if( pOp==0 ) return SQLITE_NOMEM;      pOp->iTab = pCur->iTree;      pOp->nKey = pCur->pNode->nKey;      pOp->pKey = sqliteMallocRaw( pOp->nKey );      if( sqlite_malloc_failed ) return SQLITE_NOMEM;      memcpy( pOp->pKey, pCur->pNode->pKey, pOp->nKey );      pOp->nData = pCur->pNode->nData;      pOp->pData = pCur->pNode->pData;      pOp->eOp = ROLLBACK_INSERT;      btreeLogRollbackOp(pCur->pRbtree, pOp);    }else{      sqliteFree( pCur->pNode->pData );    }    /* Actually clobber the nodes data */    pCur->pNode->pData = pData;    pCur->pNode->nData = nData;  }  return SQLITE_OK;}/* Move the cursor so that it points to an entry near pKey.** Return a success code.****     *pRes<0      The cursor is left pointing at an entry that**                  is smaller than pKey or if the table is empty**                  and the cursor is therefore left point to nothing.****     *pRes==0     The cursor is left pointing at an entry that**                  exactly matches pKey.****     *pRes>0      The cursor is left pointing at an entry that**                  is larger than pKey.*/static int memRbtreeMoveto(  RbtCursor* pCur,  const void *pKey,  int nKey,  int *pRes){  BtRbNode *pTmp = 0;  pCur->pNode = pCur->pTree->pHead;  *pRes = -1;  while( pCur->pNode && *pRes ) {    *pRes = key_compare(pCur->pNode->pKey, pCur->pNode->nKey, pKey, nKey);    pTmp = pCur->pNode;    switch( *pRes ){      case 1:    /* cursor > key */        pCur->pNode = pCur->pNode->pLeft;        break;      case -1:   /* cursor < key */        pCur->pNode = pCur->pNode->pRight;        break;    }  }   /* If (pCur->pNode == NULL), then we have failed to find a match. Set   * pCur->pNode to pTmp, which is either NULL (if the tree is empty) or the   * last node traversed in the search. In either case the relation ship   * between pTmp and the searched for key is already stored in *pRes. pTmp is   * either the successor or predecessor of the key we tried to move to. */  if( !pCur->pNode ) pCur->pNode = pTmp;  pCur->eSkip = SKIP_NONE;  return SQLITE_OK;}/*** Delete the entry that the cursor is pointing to.**** The cursor is left pointing at either the next or the previous** entry.  If the cursor is left pointing to the next entry, then ** the pCur->eSkip flag is set to SKIP_NEXT which forces the next call to ** sqliteRbtreeNext() to be a no-op.  That way, you can always call** sqliteRbtreeNext() after a delete and the cursor will be left** pointing to the first entry after the deleted entry.  Similarly,** pCur->eSkip is set to SKIP_PREV is the cursor is left pointing to** the entry prior to the deleted entry so that a subsequent call to** sqliteRbtreePrevious() will always leave the cursor pointing at the** entry immediately before the one that was deleted.*/static int memRbtreeDelete(RbtCursor* pCur){  BtRbNode *pZ;      /* The one being deleted */  BtRbNode *pChild;  /* The child of the spliced out node */  /* It is illegal to call sqliteRbtreeDelete() if we are  ** not in a transaction */  assert( pCur->pRbtree->eTransState != TRANS_NONE );  /* Make sure some other cursor isn't trying to read this same table */  if( checkReadLocks(pCur) ){    return SQLITE_LOCKED; /* The table pCur points to has a read lock */  }  pZ = pCur->pNode;  if( !pZ ){    return SQLITE_OK;  }  /* If we are not currently doing a rollback, set up a rollback op for this    * deletion */  if( pCur->pRbtree->eTransState != TRANS_ROLLBACK ){    BtRollbackOp *pOp = sqliteMalloc( sizeof(BtRollbackOp) );    if( pOp==0 ) return SQLITE_NOMEM;    pOp->iTab = pCur->iTree;    pOp->nKey = pZ->nKey;    pOp->pKey = pZ->pKey;    pOp->nData = pZ->nData;    pOp->pData = pZ->pData;    pOp->eOp = ROLLBACK_INSERT;    btreeLogRollbackOp(pCur->pRbtree, pOp);  }  /* First do a standard binary-tree delete (node pZ is to be deleted). How   * to do this depends on how many children pZ has:   *   * If pZ has no children or one child, then splice out pZ.  If pZ has two   * children, splice out the successor of pZ and replace the key and data of   * pZ with the key and data of the spliced out successor.  */  if( pZ->pLeft && pZ->pRight ){    BtRbNode *pTmp;    int dummy;    pCur->eSkip = SKIP_NONE;    memRbtreeNext(pCur, &dummy);    assert( dummy == 0 );    if( pCur->pRbtree->eTransState == TRANS_ROLLBACK ){      sqliteFree(pZ->pKey);      sqliteFree(pZ->pData);    }    pZ->pData = pCur->pNode->pData;    pZ->nData = pCur->pNode->nData;    pZ->pKey = pCur->pNode->pKey;    pZ->nKey = pCur->pNode->nKey;    pTmp = pZ;    pZ = pCur->pNode;    pCur->pNode = pTmp;    pCur->eSkip = SKIP_NEXT;  }else{    int res;    pCur->eSkip = SKIP_NONE;    memRbtreeNext(pCur, &res);    pCur->eSkip = SKIP_NEXT;    if( res ){      memRbtreeLast(pCur, &res);      memRbtreePrevious(pCur, &res);      pCur->eSkip = SKIP_PREV;    }    if( pCur->pRbtree->eTransState == TRANS_ROLLBACK ){        sqliteFree(pZ->pKey);        sqliteFree(pZ->pData);    }  }  /* pZ now points at the node to be spliced out. This block does the    * splicing. */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
在线亚洲精品福利网址导航| 国产在线精品视频| 欧美影院一区二区三区| 亚洲国产va精品久久久不卡综合 | 国产乱码精品一品二品| 久久先锋影音av鲁色资源网| 国产福利不卡视频| 亚洲色图一区二区三区| 欧美日韩国产一区| 精品一区二区三区影院在线午夜| 久久夜色精品一区| 一本色道久久综合精品竹菊| 午夜精品久久久久久久蜜桃app| 日韩一级完整毛片| 国产经典欧美精品| 亚洲男同性视频| 日韩欧美中文字幕精品| 国产成人av电影在线播放| 亚洲色图视频网站| 成人福利视频在线看| 国产免费成人在线视频| 91毛片在线观看| 丝袜亚洲另类欧美| 国产欧美一区二区精品仙草咪| 99re这里都是精品| 国产成人免费视频精品含羞草妖精| 久久精品亚洲乱码伦伦中文| 一本大道av伊人久久综合| 日本欧美韩国一区三区| 国产精品传媒在线| 日韩欧美国产精品| 色天使色偷偷av一区二区| 激情综合色丁香一区二区| 一区二区三区成人| 亚洲国产精华液网站w| 在线不卡一区二区| 91亚洲国产成人精品一区二三| 日韩—二三区免费观看av| 亚洲乱码中文字幕| 亚洲国产精品黑人久久久| 91精品国产一区二区三区蜜臀| 成人国产在线观看| 久久疯狂做爰流白浆xx| 亚洲一区二区在线免费观看视频| 久久精品在这里| 欧美一级片免费看| 欧美在线一区二区三区| 成人午夜电影网站| 精品一区二区三区视频| 亚洲无人区一区| 中文字幕亚洲一区二区va在线| 日韩精品一区二区在线| 欧美日韩综合在线| 在线观看亚洲一区| 色综合视频在线观看| 高清日韩电视剧大全免费| 美女精品一区二区| 日本不卡视频在线观看| 亚洲国产日产av| 亚洲综合视频在线| 亚洲欧美日本韩国| 中文字幕日韩av资源站| 国产亚洲1区2区3区| 精品理论电影在线| 欧美成人伊人久久综合网| 7777精品伊人久久久大香线蕉| 欧美性大战久久| 91欧美激情一区二区三区成人| 粉嫩欧美一区二区三区高清影视| 国产乱对白刺激视频不卡| 国内精品不卡在线| 国产一区二区不卡在线| 国产一区二区福利| 国产91丝袜在线18| 成人av中文字幕| 91毛片在线观看| 91成人看片片| 欧美三级电影在线观看| 欧美日韩一卡二卡三卡| 91精品国产综合久久精品app| 欧美日本视频在线| 在线观看免费成人| 欧美日韩国产中文| 日韩一区二区三区视频在线| 精品区一区二区| 久久日韩精品一区二区五区| 久久综合九色综合97婷婷| 久久色视频免费观看| 国产精品视频yy9299一区| 亚洲视频一二三区| 亚洲福利视频三区| 久久精品国产久精国产| 国产夫妻精品视频| 色综合夜色一区| 欧美夫妻性生活| 久久久久99精品国产片| 亚洲欧美激情插| 日韩电影在线一区二区三区| 蜜臀久久久久久久| 风间由美性色一区二区三区| 色欧美片视频在线观看在线视频| 精品视频在线免费观看| 精品国产免费一区二区三区四区 | 国产一区二区剧情av在线| 国产成人亚洲综合a∨婷婷| av电影在线观看一区| 欧美色老头old∨ideo| 欧美成人一区二区三区片免费| 中文字幕av在线一区二区三区| 亚洲国产美女搞黄色| 国产一区二区久久| 欧美视频一区二区三区在线观看| 精品久久久三级丝袜| 亚洲欧美日韩国产另类专区| 美女网站色91| 色综合久久99| 久久先锋影音av鲁色资源网| 亚洲一区二区三区四区中文字幕| 久久66热偷产精品| 色中色一区二区| 久久综合狠狠综合久久激情 | 午夜激情一区二区| 成人福利视频在线| 日韩视频一区在线观看| 国产精品久久久久久久久晋中 | 久久亚洲精精品中文字幕早川悠里 | 91精品国产高清一区二区三区| 国产色综合一区| 午夜视频在线观看一区二区| 国产成人免费av在线| 欧美剧情电影在线观看完整版免费励志电影 | 99视频热这里只有精品免费| 日韩一区二区三| 亚洲一区二区在线免费看| 岛国一区二区三区| 欧美精品一区二区在线观看| 五月天一区二区| 91免费看视频| 国产欧美日韩卡一| 美女视频一区二区三区| 欧美日韩免费观看一区二区三区| 国产精品毛片久久久久久| 狠狠色丁香久久婷婷综| 欧美福利视频一区| 亚洲国产精品久久久男人的天堂| 成人免费福利片| 国产欧美日韩激情| 国产美女视频91| 日韩精品一区二区三区在线观看| 香蕉影视欧美成人| 欧美影院精品一区| 亚洲一区在线观看网站| 一本大道久久a久久精二百 | 久久久久久一二三区| 日韩电影在线观看电影| 欧美伊人久久久久久久久影院 | 亚洲午夜精品在线| 91黄视频在线| 一区二区三区毛片| 色素色在线综合| 亚洲激情在线激情| 欧美专区亚洲专区| 亚洲国产日韩a在线播放| 欧美日韩亚洲丝袜制服| 天堂在线一区二区| 日韩亚洲欧美在线观看| 久久国产人妖系列| 久久综合资源网| 国产成人在线视频网址| 欧美韩国日本综合| 99精品视频一区二区| 亚洲三级在线免费| 在线看日本不卡| 日韩精品久久久久久| 精品久久久久一区二区国产| 国产一区二区调教| 国产精品素人视频| 色狠狠综合天天综合综合| 亚洲综合在线电影| 91精品国产福利| 国产精品香蕉一区二区三区| 中文字幕一区二区三区四区| 91免费观看视频| 视频一区二区三区中文字幕| 欧美电影免费观看高清完整版在线观看 | 日韩美女啊v在线免费观看| 91国产精品成人| 日本成人中文字幕| 久久久精品欧美丰满| 99久久综合精品| 午夜电影一区二区| 久久中文字幕电影| av在线播放不卡| 亚洲国产人成综合网站| 久久综合色播五月| 91在线丨porny丨国产| 日韩中文字幕av电影| 国产欧美日韩不卡免费| 欧美丝袜丝nylons| 国产成人精品免费网站|