[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [DotGNU]Portable.NET Status 22 Feb 2003
From: |
Thong \(Tum\) Nguyen |
Subject: |
RE: [DotGNU]Portable.NET Status 22 Feb 2003 |
Date: |
Sat, 22 Feb 2003 17:18:35 +1300 |
> -----Original Message-----
> From: Rhys Weatherley [mailto:address@hidden
> Sent: Saturday, 22 February 2003 4:36 p.m.
> To: Thong (Tum) Nguyen; address@hidden
> Subject: Re: [DotGNU]Portable.NET Status 22 Feb 2003
>
> On Saturday 22 February 2003 01:30 pm, Thong \(Tum\) Nguyen wrote:
> > Hi Rhys,
> >
> > I would like to help out with this one.
> >
> > Can we model it after the Java2 collections classes rather than the
.NET
> > ones?
>
> Possibly. I started with the C# collections, primarily because they
were
> familar to me and other C# programmers. But the reason why I'm
opening
> this
> up now is so that we can discuss what the generic classes need to look
> like.
> All options are on the table.
>
> > We can have ADTs like IStack, IQueue, IMap, IList with concrete
> > implementations like ArrayStack, LinkedStack, ArrayQueue,
LinkedQueue,
> > HashMap, TreeMap etc etc.
> >
> > System.Collections makes a mistake in that Stack and Queue are
concrete
> > class rather than interfaces. This makes it hard to replace the
> > underlying implementations of the ADTs.
>
> Well spotted. Yes, that is a problem with the current C# collections.
Do
> you
> want to look into these, or at least give me a pointer to them?
I'll look into it next week (or perhaps over the weekend if I have
time).
Gyro will make it easier to test (at least until portable.net's generics
is complete).
I've had a bit of experience writing generic collections (in C++).
Here's what I hope the C# ones will look like:
ICollection (base interface for all collections)
|
* Add(T)
* AddAll(ICollection<T>)
* Clear
* Contains(ICollection<T>)
* ContainsAll(ICollection<T>)
* Remove(T)
* RemoveAll(ICollection<T>)
* RetainAll(ICollection<T>)
* GetIterator
* IsEmpty
* get_Count
* ToArray
|
+--AbstractCollection (base class for all collections)
IList
|
+--AbstractList (default implementations of some methods like AddAll)
|
+--ArrayList
|
+--LinkedList
|
+--DoublyLinkedList
IMap
|
+--AbstractMap
|
+--HashMap (hash based map)
|
+--TreeMap (binary tree based map)
IMapEntry
* get_Key
* get_Value
ISet
|
+--AbstractSet
|
+--MapBackedSet
|
+--HashSet (trivial)
|
+--TreeSet (trivial)
IStack
|
+--AbstractStack
|
+--ListBackedStack (stack that uses a provided IList implementation)
|
+--ArrayStack (trivial)
|
+--LinkedListStack (trivial)
|
+--DoublyLinkedListStack (trivial)
IQueue
|
+--AbstractQueue
|
+--ListBackedQueue (stack that uses any given IList implementation)
|
+--ArrayQueue (trivial)
|
+--LinkedListQueue (trivial)
|
+--DoublyLinkedListQueue (trivial)
All the trivial collections are easily implemented. They simply call
the base (backing collection's) constructor :). Once lists and maps are
implemented, stacks, queues and sets will be easy.
>
> No matter what we do, we should have "Adapter" classes that can be
used to
> bridge the gap with the existing non-generic collection classes in C#.
> There
> are a lot of existing API's that expect ICollection, IEnumerable, etc.
>
Definitely :).
Regards,
^Tum
Re: [DotGNU]Portable.NET Status 22 Feb 2003, Ian Fung, 2003/02/22