× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Circle linked list

Nguyen Hoang Long
Mar 18, 2015
<p>This is how to implement the circle linked list using ArrayList in C#</p> <p> </p> <p>using System;<br> using System.Collections.Generic;<br> using System.Linq;<br> using System.Text;<br> using System.Collections;</p> <p>namespace ConsoleApplication1<br> {<br>     class Ring<br>     {<br>         private ArrayList ring;<br>         public Ring(int numberOfActor)<br>         {<br>             ring = new ArrayList();<br>             for (int i = 0; i &lt; numberOfActor; i++)<br>             {<br>                 ring.Add(i + 1);<br>             }<br>         }</p> <p>        public ArrayList OutputAuditionOrder(int count)<br>         {<br>             int index = count - 1;<br>             int size = ring.Count;<br>             ArrayList tmp = new ArrayList();<br>             for (int i = 0; i &lt; size; i++)<br>             {<br>                 tmp.Add(ring[i]);<br>             }<br>             ArrayList result = new ArrayList();<br>             while (size &gt; 0)<br>             {<br>                 result.Add(tmp[index]);<br>                 tmp.RemoveAt(index);<br>                 size--;<br>                 if (size &gt; 0)<br>                     index = (index + count - 1) % size;<br>                 <br>             }<br>             return result;<br>         }<br>     }<br> }</p>

Get New Tutorials Delivered to Your Inbox

New tutorials will be sent to your Inbox once a week.

comments powered by Disqus