1
|
1 /*
|
|
2 * Copyright (C) 2004-2005 by Digital Mars, www.digitalmars.com
|
|
3 * Written by Walter Bright
|
|
4 *
|
|
5 * This software is provided 'as-is', without any express or implied
|
|
6 * warranty. In no event will the authors be held liable for any damages
|
|
7 * arising from the use of this software.
|
|
8 *
|
|
9 * Permission is granted to anyone to use this software for any purpose,
|
|
10 * including commercial applications, and to alter it and redistribute it
|
|
11 * freely, in both source and binary form, subject to the following
|
|
12 * restrictions:
|
|
13 *
|
|
14 * o The origin of this software must not be misrepresented; you must not
|
|
15 * claim that you wrote the original software. If you use this software
|
|
16 * in a product, an acknowledgment in the product documentation would be
|
|
17 * appreciated but is not required.
|
|
18 * o Altered source versions must be plainly marked as such, and must not
|
|
19 * be misrepresented as being the original software.
|
|
20 * o This notice may not be removed or altered from any source
|
|
21 * distribution.
|
|
22 */
|
|
23
|
|
24 module std.typeinfo.ti_Adouble;
|
|
25
|
|
26 private import std.typeinfo.ti_double;
|
|
27
|
|
28 // double[]
|
|
29
|
|
30 class TypeInfo_Ad : TypeInfo
|
|
31 {
|
|
32 char[] toString() { return "double[]"; }
|
|
33
|
|
34 hash_t getHash(void *p)
|
|
35 { double[] s = *cast(double[]*)p;
|
|
36 size_t len = s.length;
|
|
37 auto str = s.ptr;
|
|
38 hash_t hash = 0;
|
|
39
|
|
40 while (len)
|
|
41 {
|
|
42 hash *= 9;
|
|
43 hash += (cast(uint *)str)[0];
|
|
44 hash += (cast(uint *)str)[1];
|
|
45 str++;
|
|
46 len--;
|
|
47 }
|
|
48
|
|
49 return hash;
|
|
50 }
|
|
51
|
|
52 int equals(void *p1, void *p2)
|
|
53 {
|
|
54 double[] s1 = *cast(double[]*)p1;
|
|
55 double[] s2 = *cast(double[]*)p2;
|
|
56 size_t len = s1.length;
|
|
57
|
|
58 if (len != s2.length)
|
|
59 return 0;
|
|
60 for (size_t u = 0; u < len; u++)
|
|
61 {
|
|
62 int c = TypeInfo_d._equals(s1[u], s2[u]);
|
|
63 if (c == 0)
|
|
64 return 0;
|
|
65 }
|
|
66 return 1;
|
|
67 }
|
|
68
|
|
69 int compare(void *p1, void *p2)
|
|
70 {
|
|
71 double[] s1 = *cast(double[]*)p1;
|
|
72 double[] s2 = *cast(double[]*)p2;
|
|
73 size_t len = s1.length;
|
|
74
|
|
75 if (s2.length < len)
|
|
76 len = s2.length;
|
|
77 for (size_t u = 0; u < len; u++)
|
|
78 {
|
|
79 int c = TypeInfo_d._compare(s1[u], s2[u]);
|
|
80 if (c)
|
|
81 return c;
|
|
82 }
|
|
83 return cast(int)s1.length - cast(int)s2.length;
|
|
84 }
|
|
85
|
|
86 size_t tsize()
|
|
87 {
|
|
88 return (double[]).sizeof;
|
|
89 }
|
|
90
|
|
91 uint flags()
|
|
92 {
|
|
93 return 1;
|
|
94 }
|
|
95
|
|
96 TypeInfo next()
|
|
97 {
|
|
98 return typeid(double);
|
|
99 }
|
|
100 }
|
|
101
|
|
102 // idouble[]
|
|
103
|
|
104 class TypeInfo_Ap : TypeInfo_Ad
|
|
105 {
|
|
106 char[] toString() { return "idouble[]"; }
|
|
107
|
|
108 TypeInfo next()
|
|
109 {
|
|
110 return typeid(idouble);
|
|
111 }
|
|
112 }
|