<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja">
	<id>http://comp.chem.tohoku.ac.jp/mediawiki/index.php?action=history&amp;feed=atom&amp;title=Linked_list</id>
	<title>Linked list - 版の履歴</title>
	<link rel="self" type="application/atom+xml" href="http://comp.chem.tohoku.ac.jp/mediawiki/index.php?action=history&amp;feed=atom&amp;title=Linked_list"/>
	<link rel="alternate" type="text/html" href="http://comp.chem.tohoku.ac.jp/mediawiki/index.php?title=Linked_list&amp;action=history"/>
	<updated>2026-05-26T18:33:07Z</updated>
	<subtitle>このウィキのこのページに関する変更履歴</subtitle>
	<generator>MediaWiki 1.36.2</generator>
	<entry>
		<id>http://comp.chem.tohoku.ac.jp/mediawiki/index.php?title=Linked_list&amp;diff=1112&amp;oldid=prev</id>
		<title>Hirano: ページの作成:「== Background ==  Linked list (March. 18, 2016, 11:40 UTC). In Wikipedia: The Free Encyclopedia. Retrieved from [https://en.wikipedia.org/wiki/Linked_list]    In computer…」</title>
		<link rel="alternate" type="text/html" href="http://comp.chem.tohoku.ac.jp/mediawiki/index.php?title=Linked_list&amp;diff=1112&amp;oldid=prev"/>
		<updated>2026-05-26T04:16:04Z</updated>

		<summary type="html">&lt;p&gt;ページの作成:「== Background ==  Linked list (March. 18, 2016, 11:40 UTC). In Wikipedia: The Free Encyclopedia. Retrieved from [https://en.wikipedia.org/wiki/Linked_list]    In computer…」&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Background ==&lt;br /&gt;
&lt;br /&gt;
Linked list (March. 18, 2016, 11:40 UTC). In Wikipedia: The Free Encyclopedia. Retrieved from [https://en.wikipedia.org/wiki/Linked_list] &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In computer science, a '''linked list''' is a linear collection of data elements, called nodes pointing to the next node by means of pointer. It is a data structure consisting of a group of nodes which together represent a sequence. Under the simplest form, each node is composed of data and a reference (in other words, a ''link'') to the next node in the sequence; more complex variants add additional links. This structure allows for efficient insertion or removal of elements from any position in the sequence.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;center&amp;quot;&amp;gt;[[File:Singly-linked-list.svg]]&amp;lt;br&amp;gt;&amp;lt;small&amp;gt;''A linked list whose nodes contain two fields: an integer value and a link to the next node. The last node is linked to a terminator used to signify the end of the list.''&amp;lt;/small&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Linked lists are among the simplest and most common data structures. They can be used to implement several other common abstract data types, including list (the abstract data type), stacks, queues, associative arrays, and S-expressions, though it is not uncommon to implement the other data structures directly without using a list as the basis of implementation.&lt;br /&gt;
&lt;br /&gt;
The principal benefit of a linked list over a conventional array data structure|array is that the list elements can easily be inserted or removed without reallocation or reorganization of the entire structure because the data items need not be stored contiguously in memory or on disk, while an array has to be declared in the source code, before compiling and running the program. Linked lists allow insertion and removal of nodes at any point in the list, and can do so with a constant number of operations if the link previous to the link being added or removed is maintained during list traversal.&lt;br /&gt;
&lt;br /&gt;
On the other hand, simple linked lists by themselves do not allow random access to the data, or any form of efficient indexing.  Thus, many basic operations&amp;amp;nbsp;— such as obtaining the last node of the list (assuming that the last node is not maintained as separate node reference in the list structure), or finding a node that contains a given datum, or locating the place where a new node should be inserted&amp;amp;nbsp;— may require sequential scanning of most or all of the list elements. The advantages and disadvantages of using linked lists are given below.&lt;br /&gt;
&lt;br /&gt;
===Advantages===&lt;br /&gt;
* Linked lists are a dynamic data structure, which can grow and be pruned, allocating and deallocating memory while the program is running.&lt;br /&gt;
* Insertion and deletion node operations are easily implemented in a linked list.&lt;br /&gt;
* Linear data structures such as stacks and queues are easily executed with a linked list.&lt;br /&gt;
* They can reduce access time and may expand in real time without memory overhead.&lt;br /&gt;
&lt;br /&gt;
===Disadvantages===&lt;br /&gt;
&lt;br /&gt;
* They have a tendency to use more memory due to pointers requiring extra storage space.&lt;br /&gt;
* Nodes in a linked list must be read in order from the beginning as linked lists are inherently sequential access.&lt;br /&gt;
* Nodes are stored incontiguously, greatly increasing the time required to access individual elements within the list.&lt;br /&gt;
* Difficulties arise in linked lists when it comes to reverse traversing. For instance, singly linked lists are cumbersome to navigate backwards and while doubly linked lists are somewhat easier to read, memory is wasted in allocating space for a back pointer.&lt;br /&gt;
&lt;br /&gt;
==Module structure==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;fortran&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
!! Module for linked list.&lt;br /&gt;
&lt;br /&gt;
MODULE linked_list_module&lt;br /&gt;
  USE list_data_module,ONLY: LIST_DATA&lt;br /&gt;
  IMPLICIT NONE&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  !!! The element of the list.&lt;br /&gt;
  TYPE,PRIVATE :: LINKED_LIST&lt;br /&gt;
    TYPE(LINKED_LIST), POINTER :: next&lt;br /&gt;
    TYPE(LIST_DATA)            :: DATA&lt;br /&gt;
  END TYPE LINKED_LIST&lt;br /&gt;
&lt;br /&gt;
  !!! Struct for linked list.&lt;br /&gt;
  TYPE linked_list_struct&lt;br /&gt;
    !!! pointer to the head of the list.&lt;br /&gt;
    TYPE(LINKED_LIST),POINTER :: head&lt;br /&gt;
&lt;br /&gt;
  CONTAINS&lt;br /&gt;
    PROCEDURE :: init  !!!() constructor of the struct.&lt;br /&gt;
    PROCEDURE :: size  !!!() RESULT(SIZE of the list).&lt;br /&gt;
       !!! Return the size of the list.&lt;br /&gt;
       !!! If list is empty, return 0.&lt;br /&gt;
    PROCEDURE :: add_head !!!(DATA) &lt;br /&gt;
       !!! Add data to the front of the list.&lt;br /&gt;
    PROCEDURE :: add_tail !!!(DATA) &lt;br /&gt;
       !!! Add data to the end of the list.&lt;br /&gt;
&lt;br /&gt;
    PROCEDURE :: take_head !!! () RESULT(head_DATA)&lt;br /&gt;
    PROCEDURE :: take_tail !!! () RESULT(tail_DATA)&lt;br /&gt;
       !!! Be careful with the size of the list. &lt;br /&gt;
       !!! Program will stop if the list is empty &lt;br /&gt;
       !!! while these functions are called. &lt;br /&gt;
       !&lt;br /&gt;
    PROCEDURE :: is_empty !!!()  RESULT(T/F)&lt;br /&gt;
       !!! See if the list is empty.&lt;br /&gt;
       !!! Return .TRUE. if it is.&lt;br /&gt;
       !&lt;br /&gt;
    PROCEDURE :: empty !!!() RESULT(T/F)&lt;br /&gt;
       !!! Empty current list.&lt;br /&gt;
       !!! Returns .FALSE. if the list is already empty.&lt;br /&gt;
       !!! Otherwise returns .TURE.&lt;br /&gt;
       !&lt;br /&gt;
    PROCEDURE,PRIVATE :: locate !!! (key) RESULT(loc) &lt;br /&gt;
       !!! Return the pointer to the position of DATA.&lt;br /&gt;
       !!! If multiple DATA have the same key, return position &lt;br /&gt;
       !!! of the first one.&lt;br /&gt;
       !!! If DATA with the same key does not exist, return NULL pointer.&lt;br /&gt;
       !&lt;br /&gt;
    PROCEDURE :: has !!! (key) RESULT(T/F)&lt;br /&gt;
       !!! Check if DATA with the same key exists in the list.&lt;br /&gt;
       !!! Returns .TRUE. if at least one exists.&lt;br /&gt;
       !!! Returns .FALSE. otherwise.&lt;br /&gt;
       !&lt;br /&gt;
    PROCEDURE :: get  !!! (key) RESULT(DATA)&lt;br /&gt;
       !!! Return DATA with given key.&lt;br /&gt;
       !!! If key not found, print a warning and return a DATA with &lt;br /&gt;
       !!! a value of &amp;quot;NaN&amp;quot;.  &lt;br /&gt;
       !&lt;br /&gt;
    PROCEDURE :: add !!! (DATA) RESULT(T/F)     &lt;br /&gt;
       !!! Add data with unique key.&lt;br /&gt;
       !!! If DATA with the same key doesn't exist then add data to the &lt;br /&gt;
       !!! tail of the list and return .TRUE.&lt;br /&gt;
       !!! If the DATA with the same key already exists,return .FALSE.&lt;br /&gt;
       !!! and overwrite the value with the new one.&lt;br /&gt;
       !&lt;br /&gt;
    PROCEDURE :: add_no_overwrite !!! (DATA) RESULT(T/F)&lt;br /&gt;
       !!! Same as add except that overwriting is disabled. &lt;br /&gt;
       !&lt;br /&gt;
    PROCEDURE :: overwrite !!! (DATA) RESULT(T/F)&lt;br /&gt;
       !!! Overwrite data with given key.&lt;br /&gt;
       !!! If DATA with the same key exsits, over write the value&lt;br /&gt;
       !!! and return .TRUE.&lt;br /&gt;
       !!! If DATA with the same key doesn't exist, return .FALSE. &lt;br /&gt;
       !&lt;br /&gt;
    PROCEDURE :: delete !!! (key) RESULT(T/F)&lt;br /&gt;
       !!! Delete data with given key.&lt;br /&gt;
       !!! If DATA exists and deletion succeeds, return .TRUE.&lt;br /&gt;
       !!! Otherwise, return .FALSE.&lt;br /&gt;
       !!! If there are multiple DATA with the same key, delete the &lt;br /&gt;
       !!! first found and return .TRUE.&lt;br /&gt;
       !&lt;br /&gt;
    PROCEDURE :: delete_all !!! (key) RESULT(T/F)&lt;br /&gt;
       !!! Delete all DATA that share the same key.&lt;br /&gt;
       !!! Return .TRUE. if at least one deletion is successful.&lt;br /&gt;
       !!! Otherwise, return .FALSE.&lt;br /&gt;
       !&lt;br /&gt;
    PROCEDURE :: copy !!! (list)&lt;br /&gt;
       !!! Copy the given list to current one.&lt;br /&gt;
       !!! Note that initialization is required before calling this.&lt;br /&gt;
       !&lt;br /&gt;
    PROCEDURE :: combine !!!(list) &lt;br /&gt;
       !!! This subroutine combines the list with the given one.&lt;br /&gt;
       !!! For best performace, the combine is based on&lt;br /&gt;
       !!! add_head() operations.&lt;br /&gt;
       !!!&lt;br /&gt;
       !!! Example :&lt;br /&gt;
       !!!   self=&amp;gt;   A-&amp;gt;B-&amp;gt;C    &lt;br /&gt;
       !!!   list=&amp;gt;   D-&amp;gt;E-&amp;gt;F&lt;br /&gt;
       !!! The result of combine() operation:&lt;br /&gt;
       !!!   self=&amp;gt;   F-&amp;gt;E-&amp;gt;D-&amp;gt;A-&amp;gt;B-&amp;gt;C &lt;br /&gt;
       !&lt;br /&gt;
    PROCEDURE :: divide !!!(back) &lt;br /&gt;
       !!! This subroutine divides the list into 2 halves.&lt;br /&gt;
       !!! If the length of list is odd, the extra node will&lt;br /&gt;
       !!! go in the front list.&lt;br /&gt;
       !!! Uses the fast/slow pointer strategy.&lt;br /&gt;
       !&lt;br /&gt;
    PROCEDURE :: print !!!() &lt;br /&gt;
       !!! Print all the elements of the list onto screen. &lt;br /&gt;
       !!! For debugging purposes only.&lt;br /&gt;
       !&lt;br /&gt;
&lt;br /&gt;
!!!**** These 2 sorting subroutines are not part of the struct. ***!!!&lt;br /&gt;
    !PROCEDURE :: sort_key !!!(list)&lt;br /&gt;
       !!! Sort the list in ascending order of data%key.&lt;br /&gt;
       !&lt;br /&gt;
    !PROCEDURE :: sort_val !!!(list)&lt;br /&gt;
       !!! Sort the list in ascending order of data%val.&lt;br /&gt;
       !&lt;br /&gt;
    !PROCEDURE :: merge_key !!!(a,b) RESULT(head_loc)&lt;br /&gt;
       !!! Merge two lists in ascending order of data%key into list.&lt;br /&gt;
       !!! And return the pointer to the head of new list.&lt;br /&gt;
       !&lt;br /&gt;
    !PROCEDURE :: merge_val !!!(a,b) RESULT(head_loc)&lt;br /&gt;
       !!! Merge two lists in ascending order of data%val into list.&lt;br /&gt;
       !!! And return the pointer to the head of new list.&lt;br /&gt;
       !&lt;br /&gt;
&lt;br /&gt;
    FINAL :: destroy !!!() destructor.&lt;br /&gt;
&lt;br /&gt;
      !!-----------------------PRIVATE----------------------!!&lt;br /&gt;
      !!====================================================!!&lt;br /&gt;
&lt;br /&gt;
      !!-----------------------PRIVATE----------------------!!&lt;br /&gt;
&lt;br /&gt;
  END TYPE linked_list_struct&lt;br /&gt;
&lt;br /&gt;
CONTAINS&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hirano</name></author>
	</entry>
</feed>