www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: container stuff

reply Jason House <jason.james.house gmail.com> writes:
Andrei Alexandrescu Wrote:

 On 05/26/2010 07:38 AM, Jason House wrote:
 Andrei Alexandrescu Wrote:

 On 05/25/2010 09:07 PM, Walter Bright wrote:
 Andrei Alexandrescu wrote:
 On 05/25/2010 08:31 PM, Walter Bright wrote:
 Andrei Alexandrescu wrote:
 On 05/25/2010 07:35 PM, Walter Bright wrote:
 Andrei Alexandrescu wrote:
 I've uploaded a work in progress on the container design here:

Great! Some nitpicky comments: 1. What's the difference between a value and an element?

None.

Then I suggest sticking with one or the other throughout the spec. Also, there's both an ElementType and a ValueType.

Sorry, I was wrong. ValueType is defined for keyed containers to mean the mapped type. Should I call it MappedType?

Can a container have different ElementTypes from ValueTypes?

For a hash K->V, KeyType is K, ValueType is V, and ElementType is Tuple!(K, V). Andrei

How about simple arrays? There's a lot of similarity between T[] and T[int]...

A simple array doesn't have a Tuple as the unit of storage. Indexing is a consequence of array's layout so I consider it different. Andrei

if I understand your logic, then a trie would also lack a (key,value) tuple for the element type?
May 26 2010
parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 05/26/2010 05:21 PM, Jason House wrote:
 Andrei Alexandrescu Wrote:

 On 05/26/2010 07:38 AM, Jason House wrote:
 Andrei Alexandrescu Wrote:

 On 05/25/2010 09:07 PM, Walter Bright wrote:
 Andrei Alexandrescu wrote:
 On 05/25/2010 08:31 PM, Walter Bright wrote:
 Andrei Alexandrescu wrote:
 On 05/25/2010 07:35 PM, Walter Bright wrote:
 Andrei Alexandrescu wrote:
 I've uploaded a work in progress on the container design here:

Great! Some nitpicky comments: 1. What's the difference between a value and an element?

None.

Then I suggest sticking with one or the other throughout the spec. Also, there's both an ElementType and a ValueType.

Sorry, I was wrong. ValueType is defined for keyed containers to mean the mapped type. Should I call it MappedType?

Can a container have different ElementTypes from ValueTypes?

For a hash K->V, KeyType is K, ValueType is V, and ElementType is Tuple!(K, V). Andrei

How about simple arrays? There's a lot of similarity between T[] and T[int]...

A simple array doesn't have a Tuple as the unit of storage. Indexing is a consequence of array's layout so I consider it different. Andrei

if I understand your logic, then a trie would also lack a (key,value) tuple for the element type?

I'm not sure! Andrei
May 26 2010