I am a beginner at .NET and C# programming and therefore my questions may be a little obscured. But nevertheless I try to ask for help this community.
I am programming a circular linked list using this article as help. I understand the main idea, but few things are incomprehensible for me.
- An author says in the beginning, that our list must "maintain collection semantics". Couldn't you explain, what is this collection semantics? As I understand, it is a set of some interfaces that must be implemented in our class. Is it true? And if yes – what exactly must we maintain in this class and why? Are these two interfaces in the article (ICollection, IEnumerable) enough, or these are only the most necessary ones?
In a function that searches for a node with a given value
public Node<T> Find(T item) { Node<T> node = FindNode(head, item); return node; } Node<T> FindNode(Node<T> node, T valueToCompare) { Node<T> result = null; if (comparer.Equals(node.Value, valueToCompare)) result = node; else if (result == null && node.Next != head) result = FindNode(node.Next, valueToCompare); return result; }
an author uses an
IEqualityComparer<T> comparer
object, which is initialized with a propertyEqualityComparer<T>.Default
in one of constructors. Can you please explain me an idea of using of these interface (IEqualityComparer<T>
) and class (EqualityComparer<T>
) here? I had read MSDN, but I didn't understand the principles of working and using of them.
If my questions are too general, couldn't you suggest me some resources I might look through to find answers myself and streamline concepts in my mind?