数据结构课程设计 山东大学版 文件索引


数据结构课程设计 山东大学版 文件索引 文件索引 B树实现 VC++6.0 附有报告文档
资源截图
代码片段和文件信息

#include “stdafx.h“
#include  
#include 
#include 
#include “nclass.h“


int  levelOfBtree = 0; // 初始化B树的高度 

int  IOOfDatatxt[2];//记录数据文件的读写次数

int  IOOfIndextxt[2];//记录索引文件的读写次数





int root;//根节点所在索引文件的块号

static int level; // 当前访问的节点所处的高度 
int Isum=0;//索引文件总块数
int Dsum=0;//数据文件总块数

/*linkque Iflag;//索引文件标示
linkque Dflag;//数据文件标示
*/
btnode* head=0;//指向根节点的指针
static int flag;//插入标记
static int NewTree; //临时节点块号
static int insertKey; //要插入的学号
static int insertAddress;//要插入的学号对应块的地址


extern btnode* iread(int n);//读取索引文件中第n块的节点
extern student* dread(int n);//读取数据文件只中第n块的节点
extern void iwrite(btnode *tint n);//写入节点*t到索引文件第n块
extern void dwrite(student *tint n);//写入节点*t到数据文件第n块
extern int getAddress(linkque &qint m);//取name文件中一块空块号
extern void freeAddress(linkque &qint m);//释放name文件中第n块


//初始化队列
linkque queInit()
{
linkque q;
q.front = (lnode*)malloc(sizeof(lnode));
q.rear = q.front;
q.front->next=NULL;
return q;
}

//清空队列
void queDestroy(linkque &q)
{
while(q.front)
{
q.rear=q.front->next;
free(q.front);
q.front=q.rear;
}
}

//队列的插入
void quEen(linkque &qint e)
{
lnode *p;
p=(lnode*)malloc(sizeof(lnode));
p->num=e;
p->next =NULL;
q.rear->next =p;
q.rear=p;
}

//队列的删除
int queDel(linkque &qint e)
{
lnode *p;
if (q.front==q.rear) return(-1);
p=q.front->next;
e=p->num;
q.front->next=p->next;
if (q.rear==p) q.rear=q.front;
free(p);
return(e);
}

//队列的长度
int queLength(linkque &q)
{
int i=0;
lnode *p;
p=q.front->next;
while (p)
{
++i;
p=p->next;
}
return (i);
}

linkque Iflag=queInit();//索引文件标示
linkque Dflag=queInit();//数据文件标示

//建立一个新的根结点
btnode* NewRoot(btnode* t) 
{   
    btnode* temp; 
    temp = (btnode*)malloc(sizeof(btnode)); 
    temp->d =1; 
    temp->p[0] =root; 
    temp->p[1] = NewTree; 
    temp->k[0].ID= insertKey; 
    temp->k[0].address = insertAddress; 
    levelOfBtree++; 

int index=getAddress(IflagIsum);

iwrite(tempindex);
root=index; 

delete head;      
head=temp; 
    
return head; 



//在节点中插入索引信息 
void InsertInNode(btnode* t int d) 

    int i; 
    for(i = t->d; i > d; i--)

        t->k[ i ] = t->k[i-1]; 
        t->p[i+1] = t->p[ i ]; 
    } 
    t->k[i].ID= insertKey; 
t->k[i].address=insertAddress;
t->p[i+1] = NewTree; 
    t->d++; 



// 将结点t裂解为两个节点  
void SplitNode(btnode* t int dint blocknum) 
{     
    int ij; 
    btnode* temp; 
    int temp_ktemp_a1;
   
    temp = (btnode*)malloc(sizeof(btnode)); 

//插入右边的节点中
    if (d > M/2) { 

        for(i=M-2j=(M-1)/2-1; i>=d; i--j--) { 
            temp->k[j] = t->k[ i ]; 
            temp->p[j+1] = t->p[i+1]; 
        } 

        for(i=d-1j=d-M/2-2; j>=0; i--j--) { 
            temp->k[j] = t->k[ i ]; 
            temp->p[j+1] = t->p[i+1]; 
        } 

        temp->p[0] = t->p[M/2+1];


        temp->k[d

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      11176  2010-03-22 18:04  200800300054BTree.cpp

     文件       5232  2010-03-27 11:18  200800300054data.txt

     文件      13940  2010-03-22 18:04  200800300054DebugBTree.obj

     文件      61556  2010-03-27 11:13  200800300054DebugFileIndex2.exe

     文件     210440  2010-03-27 11:13  200800300054DebugFileIndex2.ilk

     文件      38255  2010-03-08 20:57  200800300054DebugFileIndex2.map

     文件       9399  2010-03-22 17:30  200800300054DebugFileIndex2.obj

     文件    5111628  2010-03-22 17:30  200800300054DebugFileIndex2.pch

     文件     394240  2010-03-27 11:13  200800300054DebugFileIndex2.pdb

     文件       4024  2010-03-21 20:47  200800300054DebugFileIndex2.res

     文件      32149  2010-03-27 11:13  200800300054DebugFileIndex2Dlg.obj

     文件       5938  2010-03-22 17:30  200800300054DebugIOcount.obj

     文件        832  2010-03-22 17:30  200800300054DebugStdAfx.obj

     文件      58368  2010-03-27 11:18  200800300054Debugvc60.idb

     文件     380928  2010-03-07 14:29  200800300054Debugvc60.pdb

     文件      23904  2010-03-27 10:53  200800300054FileIndex2.aps

     文件       2872  2010-03-27 11:19  200800300054FileIndex2.clw

     文件       2117  2010-03-21 19:37  200800300054FileIndex2.cpp

     文件       4468  2010-03-08 20:58  200800300054FileIndex2.dsp

     文件        528  2010-03-04 22:00  200800300054FileIndex2.dsw

     文件       1368  2010-03-04 22:00  200800300054FileIndex2.h

     文件     271360  2010-03-27 11:19  200800300054FileIndex2.ncb

     文件      50688  2010-03-27 11:19  200800300054FileIndex2.opt

     文件       1237  2010-03-27 11:13  200800300054FileIndex2.plg

     文件       8339  2010-03-21 20:47  200800300054FileIndex2.rc

     文件      13607  2010-03-27 11:13  200800300054FileIndex2Dlg.cpp

     文件       1837  2010-03-11 11:18  200800300054FileIndex2Dlg.h

     文件       2605  2010-03-27 11:18  200800300054index.txt

     文件         24  2010-03-27 11:19  200800300054initialization.txt

     文件       2477  2010-03-10 16:46  200800300054IOcount.cpp

............此处省略13个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)