持久链表(具有固定大小的节点) [英] Persistent linked list (node with fixed size)

查看:46
本文介绍了持久链表(具有固定大小的节点)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


是否有人可以向我建议我可以找到信息的链接

关于''持久链表''?

我需要实现一个链表,其中每个节点都是一个类似

结构的结构:


struct Node

{

int integer_value;

char test_value [125];

}


该列表应保存在一个平面文件中,以便每次重新开始时都可以重新加载列表




提前致谢

Fabio

Hi everyone,

Is there anybody who can suggest me a link where I can find information
about ''Persistent linked list'' ?
I need to implement a linked list where every node is a structure like the
following:

struct Node
{
int integer_value;
char test_value[125];
}

The list should be saved on a flat file so that the list can be re-load at
every new start.

Thanks in advance
Fabio

推荐答案



" Fabio" < FA ************* @ libero.it>在消息中写道

news:bo ********** @ newsreader.mailgate.org ...

"Fabio" <fa*************@libero.it> wrote in message
news:bo**********@newsreader.mailgate.org...
大家好,
我需要实现一个链表,其中每个节点都是一个像
struct Node
{int / integer_value;
char test_value [125];
}
Hi everyone,

Is there anybody who can suggest me a link where I can find information
about ''Persistent linked list'' ?
I need to implement a linked list where every node is a structure like the
following:

struct Node
{
int integer_value;
char test_value[125];
}



http://www.winghands.it/download /download.html?id=2


Antonio



http://www.winghands.it/download/download.html?id=2

Antonio


你想在内存中实际使用它吗?链表?还是一个

阵列?你的结构中没有定义任何指针变量。


使用你的结构的链表可能被设置为


struct llNode {

节点myNode;

llNode * prevNode; //指向列表中的上一个条目;如果

第一次输入则为NULL

llNode * nextNode; //指向列表中的下一个条目; NULL如果最后

条目

};


您需要在结构外部添加指针以指向

列表中的第一个节点,一个头指针;


llNode * headNode;


将文件加载到内存中,你会读取每条记录,然后执行

你的函数将新节点插入列表,将节点数据传递给headNode和

节点数据。


将链表保存到磁盘时,您将遍历链表并且

将myNode中的数据写入文件。


查看 www.programmersheaven.com 。他们有一些例子

可能会有所帮助。


Paul



"法比奥" < FA ************* @ libero.it>在消息中写道

news:bo ********** @ newsreader.mailgate.org ...
Are you wanting to actually use this in memory as a linked list? Or an
array? Your struct doesn''t have any pointer variables defined in it.

A linked list using your structure might be setup as

struct llNode {
Node myNode;
llNode *prevNode; // points to previous entry in list; NULL if
first entry
llNode *nextNode; // points to next entry in list; NULL if last
entry
};

You would need an additional pointer outside of the structure to point to
the first node in the list, a head pointer;

llNode *headNode;

When loading the file into memory, you would read each record, and execute
your function to insert a new node into the list, passing the headNode and
the Node data into the function.

When saving the linked list to disk, you would traverse the linked list and
write the data in myNode to the file.

Take a look at www.programmersheaven.com . They''ve got some examples there
that might help.

Paul
When
"Fabio" <fa*************@libero.it> wrote in message
news:bo**********@newsreader.mailgate.org...
大家好,
我需要实现一个链表,其中每个节点都是一个像
struct Node
{int / integer_value;
char test_value [125];
}
列表应保存在平面文件中,以便每次重新开始时都可以重新加载列表。

提前致谢
Fabio
Hi everyone,

Is there anybody who can suggest me a link where I can find information
about ''Persistent linked list'' ?
I need to implement a linked list where every node is a structure like the
following:

struct Node
{
int integer_value;
char test_value[125];
}

The list should be saved on a flat file so that the list can be re-load at
every new start.

Thanks in advance
Fabio






Fabio写道:


Fabio wrote:

大家好,
<有没有人可以建议我一个链接,我可以找到关于''持久链表'的信息?
我需要实现一个链表,其中每个节点都是一个像<的结构以下是:

struct Node
{
int integer_value;
char test_value [125];


该列表应保存在一个平面文件中,以便列表可以重新加载到

Hi everyone,

Is there anybody who can suggest me a link where I can find information
about ''Persistent linked list'' ?
I need to implement a linked list where every node is a structure like the
following:

struct Node
{
int integer_value;
char test_value[125];
}

The list should be saved on a flat file so that the list can be re-load at
every new start.




你的具体问题是什么?


原则上这很容易:


写清单:

打开文件
所有节点


写节点

关闭文件

阅读清单:

空清单

打开文件

只要有东西要阅读

读取节点

将节点插入列表

关闭文件


哪一步给你带来麻烦?`


-

Karl Heinz Buchegger
kb ****** @ gascad.at


这篇关于持久链表(具有固定大小的节点)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆