﻿<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja">
	<id>https://wiki.blender.jp/index.php?action=history&amp;feed=atom&amp;title=Dev%3ASource%2FData_Structures%2FBLI_linklist_Tutorial</id>
	<title>Dev:Source/Data Structures/BLI linklist Tutorial - 版の履歴</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.blender.jp/index.php?action=history&amp;feed=atom&amp;title=Dev%3ASource%2FData_Structures%2FBLI_linklist_Tutorial"/>
	<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=Dev:Source/Data_Structures/BLI_linklist_Tutorial&amp;action=history"/>
	<updated>2026-04-21T13:11:12Z</updated>
	<subtitle>このウィキのこのページに関する変更履歴</subtitle>
	<generator>MediaWiki 1.31.0</generator>
	<entry>
		<id>https://wiki.blender.jp/index.php?title=Dev:Source/Data_Structures/BLI_linklist_Tutorial&amp;diff=43150&amp;oldid=prev</id>
		<title>Yamyam: 1版 をインポートしました</title>
		<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=Dev:Source/Data_Structures/BLI_linklist_Tutorial&amp;diff=43150&amp;oldid=prev"/>
		<updated>2018-06-28T17:45:48Z</updated>

		<summary type="html">&lt;p&gt;1版 をインポートしました&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ja&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← 古い版&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;2018年6月28日 (木) 17:45時点における版&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;ja&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(相違点なし)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Yamyam</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.blender.jp/index.php?title=Dev:Source/Data_Structures/BLI_linklist_Tutorial&amp;diff=43149&amp;oldid=prev</id>
		<title>wiki&gt;Brecht: moved Dev:Doc/Blender Source/BLI linklist Tutorial to Dev:Source/Data Structures/BLI linklist Tutorial</title>
		<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=Dev:Source/Data_Structures/BLI_linklist_Tutorial&amp;diff=43149&amp;oldid=prev"/>
		<updated>2011-06-15T13:42:05Z</updated>

		<summary type="html">&lt;p&gt;moved &lt;a href=&quot;/Dev:Doc/Blender_Source/BLI_linklist_Tutorial&quot; class=&quot;mw-redirect&quot; title=&quot;Dev:Doc/Blender Source/BLI linklist Tutorial&quot;&gt;Dev:Doc/Blender Source/BLI linklist Tutorial&lt;/a&gt; to &lt;a href=&quot;/Dev:Source/Data_Structures/BLI_linklist_Tutorial&quot; title=&quot;Dev:Source/Data Structures/BLI linklist Tutorial&quot;&gt;Dev:Source/Data Structures/BLI linklist Tutorial&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Using BLI_linklist=&lt;br /&gt;
&lt;br /&gt;
BLI_linklist is a basic implementation of a singly linked list. This BLI was originally coded by Daniel Dunbar (zr).&lt;br /&gt;
&lt;br /&gt;
== Initialization, Addition and Destruction==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 #include &amp;quot;BLI_linklist.h&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We need to include this header to use the linked list&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 LinkNode *linklist = NULL;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is our empty list. It is ready to be used.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 void BLI_linklist_prepend(struct [[BlenderDev/LinkNode|LinkNode]] ''''''listp, void *ptr);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is the function to add an entry to the begining of the list. The linked list can hold any type of pointer as it's value. So if we were making a list of [[BlenderDev/EditEdge|EditEdge]] pointers, and we had one called eed to add &lt;br /&gt;
to the list, we would do it like this...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 BLI_linklist_prepend(linklist,eed);&lt;br /&gt;
&lt;br /&gt;
 void BLI_linklist_prepend_arena(struct [[BlenderDev/LinkNode|LinkNode]] ''''''listp, void '''ptr, struct [[BlenderDev/MemArena|MemArena]] '''ma);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This function is for adding items to the link list using memory from a memarena rather that allocation memory each time you need to add 1 item. It reduces the number of calls to the system for more dynamic memory. Its use is not covered on this page at the moment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 void BLI_linklist_free(struct [[BlenderDev/LinkNode|LinkNode]] *list, [[BlenderDev/LinkNodeFreeFP|LinkNodeFreeFP]] freefunc);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When we are done with our list, we will need to call this function. The first parameter is obviously the list we would like to get rid of. If we did not allocate any dynamic memory for the list entries, we can pass NULL as the second parameter &lt;br /&gt;
&lt;br /&gt;
like this...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 BLI_linklist_free(linklist,NULL);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will clean up our linked list. But if you need to do something to each entry before destroying the list, you can use the the second parameter. This is a pointer to a function that will be called for each node in the linked list, passing the value in the the linked list as a parameter. So if you needed to call MEM_freeN() on each member of the linklist you would do this&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 BLI_linklist_free(linklist, MEM_freeN);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Utility Functions==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 int BLI_linklist_length(LinkNode *list)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This one is pretty self explanatory, call it with the linked list as the parameter and get and int with the number of entries in the list.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 void BLI_linklist_reverse   (struct [[BlenderDev/LinkNode|LinkNode]] ''''''listp);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, another simple one, call this function with the linked list as the parameter and its contents will be reversed. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 void BLI_linklist_apply(LinkNode *list, [[BlenderDev/LinkNodeApplyFP|LinkNodeApplyFP]] applyfunc)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is a nice one if you have a funtion that you would like to apply to each entry, much like the 2nd parameter in BLI_linklist_free. So if you had a function print(list_entry_type) that you wanted to call on each entry in the list, it would be this simple&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 BLI_linklist_apply(linklist, print);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== A Small Editmesh Example==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;BLI_linklist.h&amp;quot;&lt;br /&gt;
LinkNode *linklist = NULL;&lt;br /&gt;
&lt;br /&gt;
void foo(){ &lt;br /&gt;
     EditMesh *em = G.editMesh;&lt;br /&gt;
     EditEdge *eed; &lt;br /&gt;
     LinkNode '''linklist = NULL, '''iter;&lt;br /&gt;
     &lt;br /&gt;
     // Put all selected edges in a linked list &lt;br /&gt;
     for(eed=em-&amp;gt;edges.first;eed;eed = eed-&amp;gt;next){ &lt;br /&gt;
          if(eed-&amp;gt;f &amp;amp; SELECT){   BLI_linklist_prepend(linklist,eed);&lt;br /&gt;
          }&lt;br /&gt;
     }&lt;br /&gt;
     // reverse the list for giggles&lt;br /&gt;
     BLI_linklist_reverse(linklist);&lt;br /&gt;
     // Now we can go through our linklist of edges in the same way &lt;br /&gt;
     for(iter = linklist;iter;iter = iter-&amp;gt;next){ &lt;br /&gt;
          eed = iter-&amp;gt;link; // Now eed is equal to the eed we put in the list &lt;br /&gt;
     }&lt;br /&gt;
     BLI_linklist_free(linklist,NULL);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Script]]&lt;/div&gt;</summary>
		<author><name>wiki&gt;Brecht</name></author>
		
	</entry>
</feed>