std.collection lets rename it into std,ridiculous.

H. S. Teoh hsteoh at
Sun Feb 19 19:43:19 PST 2012

On Mon, Feb 20, 2012 at 04:19:10PM +1300, James Miller wrote:
> My feedback is that for most people's purposes, associative arrays and
> arrays (dynamic and static) are fine. PHP doesn't have a well-used
> collections library (though it does exist) but it is used by millions
> of sites every day. I don't normally need an explicit
> queue/stack/priority queue.

The convenience and flexibility of D's arrays have, for the most part,
replaced my need for explicit stacks or queues. For example, here's a

	T[] stack;
	void push(elem) {
		stack ~= elem;
	T pop() {
		T elem = stack[$-1];
		stack = stack[0..$-1];
		return elem;

Here's a queue:

	T[] queue;
	void enqueue(elem) {
		queue ~= elem;
	T dequeue() {
		T elem = queue[0];
		queue = queue[1..$];
		return elem;

It's so trivial to implement that it's hardly worth the effort to
implement a class for it.

Your mileage may vary, though.


Some ideas are so stupid that only intellectuals could believe them. -- George Orwell

More information about the Digitalmars-d mailing list