Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Linked list
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Example of internal and external storage=== To create a linked list of families and their members, using internal storage, the structure might look like the following: '''record''' ''member'' { ''// member of a family'' ''member'' next; ''string'' firstName; ''integer'' age; } '''record''' ''family'' { ''// the family itself'' ''family'' next; ''string'' lastName; ''string'' address; ''member'' members ''// head of list of members of this family'' } To print a complete list of families and their members using internal storage, write: aFamily := Families ''// start at head of families list'' '''while''' aFamily β '''null''' ''// loop through list of families'' print information about family aMember := aFamily.members ''// get head of list of this family's members'' '''while''' aMember β '''null''' ''// loop through list of members'' print information about member aMember := aMember.next aFamily := aFamily.next Using external storage, the following structures can be created: '''record''' ''node'' { ''// generic link structure'' ''node'' next; ''pointer'' data ''// generic pointer for data at node'' } '''record''' ''member'' { ''// structure for family member'' ''string'' firstName; ''integer'' age } '''record''' ''family'' { ''// structure for family'' ''string'' lastName; ''string'' address; ''node'' members ''// head of list of members of this family'' } To print a complete list of families and their members using external storage, write: famNode := Families ''// start at head of families list'' '''while''' famNode β '''null''' ''// loop through list of families'' aFamily := (family) famNode.data ''// extract family from node'' print information about family memNode := aFamily.members ''// get list of family members'' '''while''' memNode β '''null''' ''// loop through list of members'' aMember := (member)memNode.data ''// extract member from node'' print information about member memNode := memNode.next famNode := famNode.next Notice that when using external storage, an extra step is needed to extract the record from the node and cast it into the proper data type. This is because both the list of families and the list of members within the family are stored in two linked lists using the same data structure (''node''), and this language does not have parametric types. As long as the number of families that a member can belong to is known at compile time, internal storage works fine. If, however, a member needed to be included in an arbitrary number of families, with the specific number known only at run time, external storage would be necessary.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Linked list
(section)
Add topic