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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? btree_rb.c

?? sqlite源碼wince移植版
?? C
?? 第 1 頁(yè) / 共 3 頁(yè)
字號(hào):
/*** 2003 Feb 4**** The author disclaims copyright to this source code.  In place of** a legal notice, here is a blessing:****    May you do good and not evil.**    May you find forgiveness for yourself and forgive others.**    May you share freely, never taking more than you give.***************************************************************************** $Id: btree_rb.c,v 1.24.2.1 2004/06/26 14:40:05 drh Exp $**** This file implements an in-core database using Red-Black balanced** binary trees.** ** It was contributed to SQLite by anonymous on 2003-Feb-04 23:24:49 UTC.*/#include "btree.h"#include "sqliteInt.h"#include <assert.h>/*** Omit this whole file if the SQLITE_OMIT_INMEMORYDB macro is** defined.  This allows a lot of code to be omitted for installations** that do not need it.*/#ifndef SQLITE_OMIT_INMEMORYDBtypedef struct BtRbTree BtRbTree;typedef struct BtRbNode BtRbNode;typedef struct BtRollbackOp BtRollbackOp;typedef struct Rbtree Rbtree;typedef struct RbtCursor RbtCursor;/* Forward declarations */static BtOps sqliteRbtreeOps;static BtCursorOps sqliteRbtreeCursorOps;/* * During each transaction (or checkpoint), a linked-list of * "rollback-operations" is accumulated. If the transaction is rolled back, * then the list of operations must be executed (to restore the database to * it's state before the transaction started). If the transaction is to be * committed, just delete the list. * * Each operation is represented as follows, depending on the value of eOp: * * ROLLBACK_INSERT  ->  Need to insert (pKey, pData) into table iTab. * ROLLBACK_DELETE  ->  Need to delete the record (pKey) into table iTab. * ROLLBACK_CREATE  ->  Need to create table iTab. * ROLLBACK_DROP    ->  Need to drop table iTab. */struct BtRollbackOp {  u8 eOp;  int iTab;  int nKey;   void *pKey;  int nData;  void *pData;  BtRollbackOp *pNext;};/*** Legal values for BtRollbackOp.eOp:*/#define ROLLBACK_INSERT 1 /* Insert a record */#define ROLLBACK_DELETE 2 /* Delete a record */#define ROLLBACK_CREATE 3 /* Create a table */#define ROLLBACK_DROP   4 /* Drop a table */struct Rbtree {  BtOps *pOps;    /* Function table */  int aMetaData[SQLITE_N_BTREE_META];  int next_idx;   /* next available table index */  Hash tblHash;   /* All created tables, by index */  u8 isAnonymous; /* True if this Rbtree is to be deleted when closed */  u8 eTransState; /* State of this Rbtree wrt transactions */  BtRollbackOp *pTransRollback;   BtRollbackOp *pCheckRollback;  BtRollbackOp *pCheckRollbackTail;};/*** Legal values for Rbtree.eTransState.*/#define TRANS_NONE           0  /* No transaction is in progress */#define TRANS_INTRANSACTION  1  /* A transaction is in progress */#define TRANS_INCHECKPOINT   2  /* A checkpoint is in progress  */#define TRANS_ROLLBACK       3  /* We are currently rolling back a checkpoint or                                 * transaction. */struct RbtCursor {  BtCursorOps *pOps;        /* Function table */  Rbtree    *pRbtree;  BtRbTree *pTree;  int       iTree;          /* Index of pTree in pRbtree */  BtRbNode *pNode;  RbtCursor *pShared;       /* List of all cursors on the same Rbtree */  u8 eSkip;                 /* Determines if next step operation is a no-op */  u8 wrFlag;                /* True if this cursor is open for writing */};/*** Legal values for RbtCursor.eSkip.*/#define SKIP_NONE     0   /* Always step the cursor */#define SKIP_NEXT     1   /* The next sqliteRbtreeNext() is a no-op */#define SKIP_PREV     2   /* The next sqliteRbtreePrevious() is a no-op */#define SKIP_INVALID  3   /* Calls to Next() and Previous() are invalid */struct BtRbTree {  RbtCursor *pCursors;     /* All cursors pointing to this tree */  BtRbNode *pHead;         /* Head of the tree, or NULL */};struct BtRbNode {  int nKey;  void *pKey;  int nData;  void *pData;  u8 isBlack;        /* true for a black node, 0 for a red node */  BtRbNode *pParent; /* Nodes parent node, NULL for the tree head */  BtRbNode *pLeft;   /* Nodes left child, or NULL */  BtRbNode *pRight;  /* Nodes right child, or NULL */  int nBlackHeight;  /* Only used during the red-black integrity check */};/* Forward declarations */static int memRbtreeMoveto(  RbtCursor* pCur,  const void *pKey,  int nKey,  int *pRes);static int memRbtreeClearTable(Rbtree* tree, int n);static int memRbtreeNext(RbtCursor* pCur, int *pRes);static int memRbtreeLast(RbtCursor* pCur, int *pRes);static int memRbtreePrevious(RbtCursor* pCur, int *pRes);/*** This routine checks all cursors that point to the same table** as pCur points to.  If any of those cursors were opened with** wrFlag==0 then this routine returns SQLITE_LOCKED.  If all** cursors point to the same table were opened with wrFlag==1** then this routine returns SQLITE_OK.**** In addition to checking for read-locks (where a read-lock ** means a cursor opened with wrFlag==0) this routine also NULLs** out the pNode field of all other cursors.** This is necessary because an insert ** or delete might change erase the node out from under** another cursor.*/static int checkReadLocks(RbtCursor *pCur){  RbtCursor *p;  assert( pCur->wrFlag );  for(p=pCur->pTree->pCursors; p; p=p->pShared){    if( p!=pCur ){      if( p->wrFlag==0 ) return SQLITE_LOCKED;      p->pNode = 0;    }  }  return SQLITE_OK;}/* * The key-compare function for the red-black trees. Returns as follows: * * (key1 < key2)             -1 * (key1 == key2)             0  * (key1 > key2)              1 * * Keys are compared using memcmp(). If one key is an exact prefix of the * other, then the shorter key is less than the longer key. */static int key_compare(void const*pKey1, int nKey1, void const*pKey2, int nKey2){  int mcmp = memcmp(pKey1, pKey2, (nKey1 <= nKey2)?nKey1:nKey2);  if( mcmp == 0){    if( nKey1 == nKey2 ) return 0;    return ((nKey1 < nKey2)?-1:1);  }  return ((mcmp>0)?1:-1);}/* * Perform the LEFT-rotate transformation on node X of tree pTree. This * transform is part of the red-black balancing code. * *        |                   | *        X                   Y *       / \                 / \ *      a   Y               X   c *         / \             / \ *        b   c           a   b * *      BEFORE              AFTER */static void leftRotate(BtRbTree *pTree, BtRbNode *pX){  BtRbNode *pY;  BtRbNode *pb;  pY = pX->pRight;  pb = pY->pLeft;  pY->pParent = pX->pParent;  if( pX->pParent ){    if( pX->pParent->pLeft == pX ) pX->pParent->pLeft = pY;    else pX->pParent->pRight = pY;  }  pY->pLeft = pX;  pX->pParent = pY;  pX->pRight = pb;  if( pb ) pb->pParent = pX;  if( pTree->pHead == pX ) pTree->pHead = pY;}/* * Perform the RIGHT-rotate transformation on node X of tree pTree. This * transform is part of the red-black balancing code. * *        |                   | *        X                   Y *       / \                 / \ *      Y   c               a   X *     / \                     / \ *    a   b                   b   c * *      BEFORE              AFTER */static void rightRotate(BtRbTree *pTree, BtRbNode *pX){  BtRbNode *pY;  BtRbNode *pb;  pY = pX->pLeft;  pb = pY->pRight;  pY->pParent = pX->pParent;  if( pX->pParent ){    if( pX->pParent->pLeft == pX ) pX->pParent->pLeft = pY;    else pX->pParent->pRight = pY;  }  pY->pRight = pX;  pX->pParent = pY;  pX->pLeft = pb;  if( pb ) pb->pParent = pX;  if( pTree->pHead == pX ) pTree->pHead = pY;}/* * A string-manipulation helper function for check_redblack_tree(). If (orig == * NULL) a copy of val is returned. If (orig != NULL) then a copy of the * * concatenation of orig and val is returned. The original orig is deleted * (using sqliteFree()). */static char *append_val(char * orig, char const * val){  char *z;  if( !orig ){    z = sqliteStrDup( val );  } else{    z = 0;    sqliteSetString(&z, orig, val, (char*)0);    sqliteFree( orig );  }  return z;}/* * Append a string representation of the entire node to orig and return it. * This is used to produce debugging information if check_redblack_tree() finds * a problem with a red-black binary tree. */static char *append_node(char * orig, BtRbNode *pNode, int indent){  char buf[128];  int i;  for( i=0; i<indent; i++ ){      orig = append_val(orig, " ");  }  sprintf(buf, "%p", pNode);  orig = append_val(orig, buf);  if( pNode ){    indent += 3;    if( pNode->isBlack ){      orig = append_val(orig, " B \n");    }else{      orig = append_val(orig, " R \n");    }    orig = append_node( orig, pNode->pLeft, indent );    orig = append_node( orig, pNode->pRight, indent );  }else{    orig = append_val(orig, "\n");  }  return orig;}/* * Print a representation of a node to stdout. This function is only included * so you can call it from within a debugger if things get really bad.  It * is not called from anyplace in the code. */static void print_node(BtRbNode *pNode){    char * str = append_node(0, pNode, 0);    printf("%s", str);    /* Suppress a warning message about print_node() being unused */    (void)print_node;}/*  * Check the following properties of the red-black tree: * (1) - If a node is red, both of it's children are black * (2) - Each path from a given node to a leaf (NULL) node passes thru the *       same number of black nodes  * * If there is a problem, append a description (using append_val() ) to *msg. */static void check_redblack_tree(BtRbTree * tree, char ** msg){  BtRbNode *pNode;  /* 0 -> came from parent    * 1 -> came from left   * 2 -> came from right */  int prev_step = 0;  pNode = tree->pHead;  while( pNode ){    switch( prev_step ){      case 0:        if( pNode->pLeft ){          pNode = pNode->pLeft;        }else{           prev_step = 1;        }        break;      case 1:        if( pNode->pRight ){          pNode = pNode->pRight;          prev_step = 0;        }else{          prev_step = 2;        }        break;      case 2:        /* Check red-black property (1) */        if( !pNode->isBlack &&            ( (pNode->pLeft && !pNode->pLeft->isBlack) ||              (pNode->pRight && !pNode->pRight->isBlack) )          ){          char buf[128];          sprintf(buf, "Red node with red child at %p\n", pNode);          *msg = append_val(*msg, buf);          *msg = append_node(*msg, tree->pHead, 0);          *msg = append_val(*msg, "\n");        }        /* Check red-black property (2) */        {           int leftHeight = 0;          int rightHeight = 0;          if( pNode->pLeft ){            leftHeight += pNode->pLeft->nBlackHeight;            leftHeight += (pNode->pLeft->isBlack?1:0);          }          if( pNode->pRight ){            rightHeight += pNode->pRight->nBlackHeight;            rightHeight += (pNode->pRight->isBlack?1:0);          }          if( leftHeight != rightHeight ){            char buf[128];            sprintf(buf, "Different black-heights at %p\n", pNode);            *msg = append_val(*msg, buf);            *msg = append_node(*msg, tree->pHead, 0);            *msg = append_val(*msg, "\n");          }          pNode->nBlackHeight = leftHeight;        }        if( pNode->pParent ){          if( pNode == pNode->pParent->pLeft ) prev_step = 1;          else prev_step = 2;        }        pNode = pNode->pParent;        break;      default: assert(0);    }  }} /* * Node pX has just been inserted into pTree (by code in sqliteRbtreeInsert()). * It is possible that pX is a red node with a red parent, which is a violation * of the red-black tree properties. This function performs rotations and  * color changes to rebalance the tree */static void do_insert_balancing(BtRbTree *pTree, BtRbNode *pX){  /* In the first iteration of this loop, pX points to the red node just   * inserted in the tree. If the parent of pX exists (pX is not the root   * node) and is red, then the properties of the red-black tree are   * violated.   *   * At the start of any subsequent iterations, pX points to a red node   * with a red parent. In all other respects the tree is a legal red-black   * binary tree. */  while( pX != pTree->pHead && !pX->pParent->isBlack ){    BtRbNode *pUncle;    BtRbNode *pGrandparent;    /* Grandparent of pX must exist and must be black. */    pGrandparent = pX->pParent->pParent;    assert( pGrandparent );    assert( pGrandparent->isBlack );    /* Uncle of pX may or may not exist. */    if( pX->pParent == pGrandparent->pLeft )       pUncle = pGrandparent->pRight;    else       pUncle = pGrandparent->pLeft;    /* If the uncle of pX exists and is red, we do the following:     *       |                 |     *      G(b)              G(r)     *      /  \              /  \             *   U(r)   P(r)       U(b)  P(b)     *            \                \     *           X(r)              X(r)     *     *     BEFORE             AFTER     * pX is then set to G. If the parent of G is red, then the while loop     * will run again.  */    if( pUncle && !pUncle->isBlack ){      pGrandparent->isBlack = 0;      pUncle->isBlack = 1;      pX->pParent->isBlack = 1;      pX = pGrandparent;    }else{      if( pX->pParent == pGrandparent->pLeft ){        if( pX == pX->pParent->pRight ){          /* If pX is a right-child, do the following transform, essentially           * to change pX into a left-child:            *       |                  |            *      G(b)               G(b)           *      /  \               /  \                   *   P(r)   U(b)        X(r)  U(b)           *      \                /           *     X(r)            P(r) <-- new X           *           *     BEFORE             AFTER           */          pX = pX->pParent;          leftRotate(pTree, pX);        }        /* Do the following transform, which balances the tree :)          *       |                  |          *      G(b)               P(b)         *      /  \               /  \                 *   P(r)   U(b)        X(r)  G(r)         *    /                         \         *  X(r)                        U(b)         *         *     BEFORE             AFTER         */        assert( pGrandparent == pX->pParent->pParent );        pGrandparent->isBlack = 0;        pX->pParent->isBlack = 1;        rightRotate( pTree, pGrandparent );      }else{        /* This code is symetric to the illustrated case above. */        if( pX == pX->pParent->pLeft ){          pX = pX->pParent;          rightRotate(pTree, pX);        }        assert( pGrandparent == pX->pParent->pParent );        pGrandparent->isBlack = 0;        pX->pParent->isBlack = 1;        leftRotate( pTree, pGrandparent );      }    }  }  pTree->pHead->isBlack = 1;}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区三区国产精华| 国产剧情一区二区三区| 一区二区三区在线观看视频| 欧美激情一区三区| 波多野结衣在线一区| 国产成人av福利| 国产二区国产一区在线观看| 国产成人在线网站| 日韩国产欧美三级| 日日夜夜精品免费视频| 男人的j进女人的j一区| 久久99精品国产91久久来源| 亚洲免费av高清| 久久精品视频免费| 国产欧美一区二区精品久导航 | 国产精品动漫网站| 中文字幕一区av| 中文字幕日本不卡| 一区二区三区国产精品| 亚洲成人av福利| 欧美96一区二区免费视频| 久草在线在线精品观看| 国产精品18久久久久久vr| 国产a级毛片一区| 99精品视频中文字幕| 在线看国产一区| 日韩欧美综合在线| 中文成人av在线| 亚洲精品伦理在线| 日日夜夜一区二区| 亚洲一区免费视频| 免费观看在线综合| 大白屁股一区二区视频| 91成人国产精品| 69精品人人人人| 在线日韩一区二区| 日韩免费一区二区| 日韩免费高清av| 国产精品伦一区二区三级视频| 精品日韩av一区二区| 国产日产精品1区| 一区二区不卡在线播放| 天天综合天天综合色| 国产一区美女在线| 91九色最新地址| 日韩欧美电影一区| 亚洲视频小说图片| 麻豆高清免费国产一区| 99麻豆久久久国产精品免费优播| 国产丶欧美丶日本不卡视频| 一道本成人在线| 精品福利一区二区三区免费视频| 精品国产免费一区二区三区四区| 国产精品久久夜| 亚洲一二三四区不卡| 国产一区二区电影| 丁香亚洲综合激情啪啪综合| 91成人看片片| 中文字幕国产精品一区二区| 亚洲成人tv网| 粉嫩高潮美女一区二区三区| 欧美高清视频www夜色资源网| 欧美日韩国产成人在线免费| 欧美激情一区二区三区四区| 视频一区二区国产| 91亚洲国产成人精品一区二三| 99久久婷婷国产| 精品福利在线导航| 日韩激情视频网站| 色噜噜狠狠一区二区三区果冻| 91国内精品野花午夜精品| 欧美色综合天天久久综合精品| 91精品国产欧美日韩| 欧美大片拔萝卜| 亚洲国产成人91porn| 成人教育av在线| 精品久久久三级丝袜| 国产免费成人在线视频| 亚洲青青青在线视频| 春色校园综合激情亚洲| 久久久亚洲国产美女国产盗摄| 欧美激情一区二区三区在线| 理论电影国产精品| 91精品国产福利在线观看| 一区二区三区产品免费精品久久75| 首页亚洲欧美制服丝腿| 国产成人精品网址| 在线观看亚洲精品视频| 国产精品传媒入口麻豆| 午夜伊人狠狠久久| 欧美亚洲一区二区在线观看| 一色屋精品亚洲香蕉网站| 国产jizzjizz一区二区| 久久精品夜夜夜夜久久| 国内精品第一页| 精品精品国产高清一毛片一天堂| 国产午夜一区二区三区| 亚洲一区免费视频| 欧美无乱码久久久免费午夜一区 | 亚洲日本电影在线| 成人性生交大片免费看中文网站| 欧美日韩国产首页在线观看| 最近中文字幕一区二区三区| 成人黄色大片在线观看| 中文字幕精品一区| 99久久伊人精品| 亚洲精品欧美专区| 色老汉av一区二区三区| 亚洲在线视频一区| 欧美日韩在线三级| 国产精品福利电影一区二区三区四区| 视频在线观看一区| 欧美一区国产二区| 精油按摩中文字幕久久| 久久综合色综合88| 成人午夜电影小说| 日韩毛片视频在线看| 色婷婷激情综合| 日韩黄色免费网站| 色88888久久久久久影院野外| 精品成人一区二区三区| 国产精品一区二区黑丝| 欧美极品aⅴ影院| aaa欧美色吧激情视频| 亚洲综合视频网| 91精品蜜臀在线一区尤物| 一区二区三区中文字幕精品精品 | 欧美精品一区二区三区蜜臀 | 成人av先锋影音| 亚洲三级小视频| 国产成人免费视频| ㊣最新国产の精品bt伙计久久| 激情综合网激情| 欧美激情综合五月色丁香小说| 国产尤物一区二区| 中文字幕在线一区免费| 欧美日韩小视频| 国产伦精一区二区三区| 亚洲天堂成人网| 91精品国产全国免费观看 | 麻豆91免费观看| 国产婷婷色一区二区三区在线| 老汉av免费一区二区三区 | 欧美一区中文字幕| 国产精品影音先锋| 一级做a爱片久久| 精品日韩欧美一区二区| 91尤物视频在线观看| 午夜视频一区二区| 国产人成一区二区三区影院| 色婷婷亚洲综合| 伊人开心综合网| 日韩欧美国产综合一区| av在线不卡电影| 免费观看一级欧美片| 一区在线观看视频| 日韩三级视频在线观看| kk眼镜猥琐国模调教系列一区二区 | 狠狠色丁香久久婷婷综| 亚洲色图视频网| 色综合久久综合| 精品亚洲成a人| 久久精品在线免费观看| 欧美日韩精品二区第二页| 亚洲第一综合色| 国产欧美一区视频| 3atv一区二区三区| 一本色道久久综合亚洲精品按摩| 亚洲精品水蜜桃| 久久精品欧美日韩精品| 欧美三级电影在线观看| 国产99久久久精品| 亚洲欧美激情视频在线观看一区二区三区 | 国产夜色精品一区二区av| 欧美丝袜丝交足nylons图片| 国产成人av一区| 久久99久久精品欧美| 午夜精品一区二区三区免费视频| 欧美日韩大陆在线| 色吊一区二区三区| www.久久精品| 国产成人无遮挡在线视频| 精品一区二区三区香蕉蜜桃| 性欧美疯狂xxxxbbbb| 亚洲人成网站影音先锋播放| 欧美亚洲国产一区二区三区va | 成人欧美一区二区三区在线播放| 91久久精品一区二区三区| 国产成人午夜视频| 亚洲午夜久久久久久久久久久| 日韩一级高清毛片| 欧美日本在线播放| 国产在线播放一区| 亚洲最新视频在线观看| 国产精品毛片久久久久久久| 久久久久99精品一区| 欧美精品一区男女天堂| 精品成人一区二区三区| 欧美va天堂va视频va在线| 日韩精品一区二区三区在线观看|