Skip to Content
C# Data Structures and Algorithms
book

C# Data Structures and Algorithms

by Marcin Jamro
April 2018
Intermediate to advanced content levelIntermediate to advanced
292 pages
6h 44m
English
Packt Publishing
Content preview from C# Data Structures and Algorithms

Implementation

After the short introduction to the topic of circular-linked lists, it is time to take a look at the implementation code. Let's start with the following code snippet:

public class CircularLinkedList<T> : LinkedList<T> 
{ 
    public new IEnumerator GetEnumerator() 
    { 
        return new CircularLinkedListEnumerator<T>(this); 
    } 
} 

The implementation of the circular-linked list can be created as a generic class that extends LinkedList, as shown in the preceding code. It is worth mentioning the implementation of the GetEnumerator method, which uses the CircularLinkedListEnumerator class. By creating it, you will be able to indefinitely iterate through all the elements of the circular-linked list, using the foreach loop.

The code of the CircularLinkedListEnumerator ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning Data Structures and Algorithms in C#

Beginning Data Structures and Algorithms in C#

Marcin Jamro

Publisher Resources

ISBN: 9781788833738Supplemental Content