We’ve seen in Chapters 12 and 13 that common information can be placed in an array of memory locations to be searched or sorted. In this chapter, we’re going to place directory information, like that found by the ls utility, into a linked list. A linked list contains a memory allocation (malloc) for each node of information that we want to store. Each allocation also contains a pointer to the next piece of information. There is also a head node that points to the beginning of the list. Another type of linked list is bidirectional. It has next and prev members and can be navigated in either direction.

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

Creating and Sorting a Linked List

  • John Schwartzman

摘要

We’ve seen in Chapters 12 and 13 that common information can be placed in an array of memory locations to be searched or sorted. In this chapter, we’re going to place directory information, like that found by the ls utility, into a linked list. A linked list contains a memory allocation (malloc) for each node of information that we want to store. Each allocation also contains a pointer to the next piece of information. There is also a head node that points to the beginning of the list. Another type of linked list is bidirectional. It has next and prev members and can be navigated in either direction.