sorting associative array's keys by values

maarten van damme maartenvd1994 at gmail.com
Sat Jun 16 15:28:07 PDT 2012


I wanted to catch it because I could not for the life of me understand
how downloading the exact same page twice could alter it's contents in
such a way that it causes the program to crash.

There's something really strange going on (or maybe I'm just too tired
to see the obvious)
My code literally reads

				if(debugtemp){
					writeln(tradeDocument[0..100]);
					writeln(tradeDocument.countUntil("<div class=\""));
					stdout.flush();
				}

And the output I get is

P-BODY SHRUG</h1>
                            <span class="level">Level 1</span><br />(Uncraftable
)

150
<div class="item unique" id="7088388" data="620,20,6" search="level:1;craftable:
false;">

0

Now either I'm going crazy or std.algorithm sees ghosts apearing.

That isn't the worst part, that is

tradeDocument=tradeDocument[1..$];
				
tradeDocument=tradeDocument[tradeDocument.countUntil("<div
class=\"")..$];//go to the next element

crashing immediatly after the previous piece of code. So in reality
std.algorithm sees an ellement that isn't there, says it's at index 0
and a second later my program crashes on the statement x=x[0..$]
What on earth is going on?

I use methods from
import std.algorithm;
import std.array;
import std.stdio;
import std.string;
and no pointers, aren't they supposed to be a subset of safeD so we
can rule out memory corruption?
(I've confirmed this behaviour on two different machines)


More information about the Digitalmars-d-learn mailing list