About std.container.RedBlackTree

Steven Schveighoffer schveiguy at yahoo.com
Thu Jan 13 08:27:36 PST 2011


On Wed, 12 Jan 2011 03:45:11 -0500, Lars T. Kyllingstad  
<public at kyllingen.nospamnet> wrote:

> On Tue, 11 Jan 2011 15:13:13 +0100, spir wrote:
>
>> On 01/11/2011 02:22 PM, Steven Schveighoffer wrote:
>>>> A tree is a kind of set, so instead of "insert()" I'd like a name like
>>>> "add()".
>>>> (But maybe this is not standard in D).
>>>
>>> The function names must be consistent across containers, because the
>>> point is that complexity and semantic requirements are attached to the
>>> function name.  The function names were decided long ago by Andrei, and
>>> I don't think insert is a bad name (I believe std::set and std::map in
>>> C++ STL uses insert).
>>
>> I have thought at this naming issue, precisely, for a while. "add" is
>> bad because of connotation with "addition". D does not use '+' as
>> operator for putting new elements in a container: this is a very
>> sensible choice imo.
>> "insert" is bad because of "in-between" connotation: does not fit when
>> putting an element at the end of a seq, even less for unordered
>> containers. "put" instead seems to me the right term, obvious and
>> general enough: one puts a new element in there. This can nicely adapt
>> to very diverse container types such as sequences including stacks (no
>> explicite index --> put at end), sets/AAs, trees,...
>
> I seem to remember this being discussed before, and 'put' being rejected
> for fear of confusion with the output range interface.

technically, it is an output range ;)

-Steve


More information about the Digitalmars-d mailing list