Mercurial > projects > ldc
comparison lphobos/internal/qsort2.d @ 109:5ab8e92611f9 trunk
[svn r113] Added initial support for associative arrays (AAs).
Fixed some problems with the string runtime support functions.
Fixed initialization of array of structs.
Fixed slice assignment where LHS is slice but RHS is dynamic array.
Fixed problems with result of assignment expressions.
Fixed foreach problems with key type mismatches.
author | lindquist |
---|---|
date | Wed, 21 Nov 2007 04:13:15 +0100 |
parents | 61615fa85940 |
children | 373489eeaf90 |
comparison
equal
deleted
inserted
replaced
108:288fe1029e1f | 109:5ab8e92611f9 |
---|---|
12 | 12 |
13 //debug=qsort; | 13 //debug=qsort; |
14 | 14 |
15 import std.c.stdlib; | 15 import std.c.stdlib; |
16 | 16 |
17 pragma(LLVM_internal, "notypeinfo") | |
17 struct Array | 18 struct Array |
18 { | 19 { |
19 size_t length; | 20 size_t length; |
20 void *ptr; | 21 void *ptr; |
21 } | 22 } |
25 extern (C) int cmp(void* p1, void* p2) | 26 extern (C) int cmp(void* p1, void* p2) |
26 { | 27 { |
27 return tiglobal.compare(p1, p2); | 28 return tiglobal.compare(p1, p2); |
28 } | 29 } |
29 | 30 |
30 extern (C) long _adSort(Array a, TypeInfo ti) | 31 extern (C) Array _adSort(Array a, TypeInfo ti) |
31 { | 32 { |
32 synchronized | 33 synchronized |
33 { | 34 { |
34 tiglobal = ti; | 35 tiglobal = ti; |
35 std.c.stdlib.qsort(a.ptr, a.length, cast(size_t)ti.tsize(), &cmp); | 36 std.c.stdlib.qsort(a.ptr, a.length, cast(size_t)ti.tsize(), &cmp); |
36 } | 37 } |
37 return *cast(long*)(&a); | 38 return a; |
38 } | 39 } |
39 | 40 |
40 | 41 |
41 | 42 |
42 unittest | 43 unittest |