Re: What wrong did i do? (key in hashtable is always null)

2009-12-31 Thread The Anh Tran
bearophile wrote: This was my version, maybe it solves some of your problems: http://shootout.alioth.debian.org/debian/benchmark.php?test=knucleotide&lang=gdc&id=2 I haven't used my dlibs here, so for example that sort in the middle is long and ugly (and not fully correct, that opCmp doesn't co

Re: What wrong did i do? (key in hashtable is always null)

2009-12-31 Thread The Anh Tran
grauzone wrote: Is your opCmp/toHash really called? Maybe the function signature is off, and dmd doesn't "find" the function. Just a guess, I don't really know how this D2 stuff works. toHash + opCmp are called. The awkward is that, most of those functions are copied & pasted from C. They wor

What wrong did i do? (key in hashtable is always null)

2009-12-30 Thread The Anh Tran
This is just a small D exercise. I port c++ knucleotide from shootout.alioth.debian.org Issue 1: If i manually listing hashtable contents, the key does exist in that ht. But (key in hash_table) always yield null. Worse, if i use: "auto val = ht[key]", an exception is thrown. Problem code is fr

Re: Expression template in D struct

2009-05-06 Thread The Anh Tran
Trass3r wrote: The Anh Tran schrieb: One of my C++ struct is Vector3. It is a wrapper from D3DXVECTOR3. I would like to use expression template to calculate where to point the gun. In C++, it is provided by boost::proto or boost::ublas. You calculate where to point the gun at compile-time

Expression template in D struct

2009-05-06 Thread The Anh Tran
Hi, I'm converting my pet project from C++ to D. It is an aimbot game cheat. One of my C++ struct is Vector3. It is a wrapper from D3DXVECTOR3. I would like to use expression template to calculate where to point the gun. In C++, it is provided by boost::proto or boost::ublas. My naive implemen

Re: lvalue - opIndexAssign - Tango

2009-03-15 Thread The Anh Tran
downs wrote: Take a look at tools.behave_as (for phobos). It only works properly with built-in types though. http://dsource.org/projects/scrapple/browser/trunk/tools/tools/behave_as.d It should let you implement a HashMap that supports += and similar, at least for built-ins. Many thanks. No of

Re: lvalue - opIndexAssign - Tango

2009-03-14 Thread The Anh Tran
Daniel Keep wrote: You could try the Tango IRC channel: That, or the Tango forums: http://dsource.org/projects/tango/forums You can report problems with Tango via the ticket system: http://dsource.org/projects/tango/report ("New Ticket" is down the bottom of the page.) I tried to register. Bu

lvalue - opIndexAssign - Tango

2009-03-13 Thread The Anh Tran
Hi, When porting from c++ to D, i encounter this strange discrimination: 1. Built-in AA: int[int] arr; arr[123] += 12345; arr[321]++; 2. Tango HashMap: auto hm = new HashMap!(int, int)(); hm[123] += 12345; // error not lvalue hm[123]++; // err

CTFE - filling an array

2008-12-09 Thread The Anh Tran
Hi, I would like to pre-create a double array, each element is calculated by a function. //- import std.stdio; import std.conv; import std.string; template f(int N) { bool fn(double[] tb) { for (int i = 1; i <