I am implementing an AVL binary tree data structure in C # .NET 2.0 (possibly moving to 3.5). I have this to the extent that it passes my initial unit tests without requiring any framework level interfaces.
But now, just looking at FCL, I see a whole bunch of interfaces, both non-general and general, that I could implement so that my class plays perfectly with language functions and other data structures.
At the moment, the only obvious choice (at least for me) is one of the Enumeration-style interfaces, which allows the caller to use the tree in a foreach loop and possibly later Linq. But which one (or more)?
Here are the interfaces that I am currently considering:
- IEnumerable and IEnumerable
<T> - IEnumerator and IEnumerator
<T> - IComparable and IComparable
<T> - IComparer and IComparer
<T> - ICollection and ICollection
<T> - IEquatable and IEquatable
<T> - IEqualityComparer and IEqualityComparer
<T> - Icloneable
- Iconvertible
Are there any published recommendations, both online and in book format, that contain recommendations on which infrastructure interfaces should be implemented and when?
Obviously, for some interfaces, if you do not want to provide this functionality, just do not implement the entire interface. But there seem to be certain conventions in FCL classes (such as Collection classes) that you might also need to consider when creating custom data structures.
, IComparer IEqualityComparer, IEnumerable IEnumerator? , , - ? ..
, , , .