Changeset 211
- Timestamp:
- 08/22/10 21:53:08 (1 year ago)
- Files:
-
- trunk/alloc.d (modified) (10 diffs)
- trunk/base.d (modified) (13 diffs)
- trunk/cor.d (modified) (6 diffs)
- trunk/infotheory.d (modified) (3 diffs)
- trunk/random.d (modified) (2 diffs)
- trunk/regress.d (modified) (6 diffs)
- trunk/summary.d (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/alloc.d
r209 r211 601 601 uint num; 602 602 uint upTo; 603 uint front() {603 @property size_t front() { 604 604 return num; 605 605 } … … 607 607 num++; 608 608 } 609 bool empty() {609 @property bool empty() { 610 610 return num >= upTo; 611 611 } … … 758 758 public: 759 759 /// 760 void popFront() { 760 void popFront() 761 in { 762 assert(!empty); 763 } body { 761 764 this._length--; 762 765 if(next is null) { … … 786 789 /// 787 790 static if(vals) { 788 ref Unqual!(K) front() { 791 @property ref Unqual!(K) front() 792 in { 793 assert(!empty); 794 } body { 789 795 return *frontElem; 790 796 } 791 797 } else { 792 Unqual!(K) front() { 798 @property Unqual!(K) front() 799 in { 800 assert(!empty); 801 } body { 793 802 return *frontElem; 794 803 } … … 796 805 797 806 /// 798 bool empty() {807 @property bool empty() { 799 808 return index == size_t.max; 800 809 } 801 810 802 811 /// 803 size_t length() {812 @property size_t length() { 804 813 return _length; 814 } 815 816 /// 817 @property typeof(this) save() { 818 return this; 805 819 } 806 820 } … … 1072 1086 1073 1087 /// 1074 size_t length() const {1088 @property size_t length() const { 1075 1089 return _length; 1076 1090 } … … 1423 1437 1424 1438 /// 1425 size_t length() {1439 @property size_t length() { 1426 1440 return _length; 1427 1441 } … … 1998 2012 1999 2013 /**Number of elements in the tree.*/ 2000 size_t length() const pure nothrow @property {2014 @property size_t length() const pure nothrow @property { 2001 2015 return _length; 2002 2016 } … … 2095 2109 2096 2110 /// 2097 size_t length() const pure nothrow {2111 @property size_t length() const pure nothrow { 2098 2112 return tree.length; 2099 2113 } … … 2166 2180 2167 2181 /// 2168 size_t length() const pure nothrow {2182 @property size_t length() const pure nothrow { 2169 2183 return tree.length; 2170 2184 } trunk/base.d
r209 r211 511 511 } 512 512 513 size_t length() {513 @property size_t length() { 514 514 return indices.length; 515 515 } … … 796 796 tn--; 797 797 fp++; 798 auto ret = classA.front ();798 auto ret = classA.front; 799 799 classA.popFront(); 800 800 return ret; … … 804 804 fn--; 805 805 tp++; 806 auto ret = classB.front ();806 auto ret = classB.front; 807 807 classB.popFront(); 808 808 return ret; … … 811 811 double area = 0; 812 812 while(!classA.empty && !classB.empty) { 813 if(classA.front () < classB.front()) {813 if(classA.front < classB.front) { 814 814 currentVal = popA(); 815 815 } else { … … 818 818 819 819 // Handle ties. 820 while(!classA.empty && classA.front ()== currentVal) {820 while(!classA.empty && classA.front == currentVal) { 821 821 popA(); 822 822 } 823 823 824 while(!classB.empty && classB.front ()== currentVal) {824 while(!classB.empty && classB.front == currentVal) { 825 825 popB(); 826 826 } … … 931 931 } 932 932 933 /**A struct that generates all possible permutations of a sequence. Due to 934 * some optimizations done under the hood, this works as an input range if 935 * T.sizeof > 1, or a forward range if T.sizeof == 1. 933 /**A struct that generates all possible permutations of a sequence. 936 934 * 937 935 * Note: Permutations are output in undefined order. … … 1023 1021 * depending on whether bufType == Buf.DUP or Buf.RECYCLE. 1024 1022 */ 1025 PermArray front() {1023 @property PermArray front() { 1026 1024 static if(bufType == Buffer.DUP) { 1027 1025 return perm[0..len].dup; … … 1064 1062 1065 1063 /// 1066 bool empty() @property{1064 @property bool empty() { 1067 1065 return nPerms == 0; 1068 1066 } … … 1070 1068 /**The number of permutations left. 1071 1069 */ 1072 size_t length() const pure nothrow {1070 @property size_t length() const pure nothrow { 1073 1071 return nPerms; 1072 } 1073 1074 /// 1075 @property typeof(this) save() { 1076 auto ret = this; 1077 static if(T.sizeof > 1) { 1078 ret.perm = (ret.perm[0..len].dup).ptr; 1079 } 1080 return ret; 1074 1081 } 1075 1082 } … … 1305 1312 } 1306 1313 1307 CombArray front() {1314 @property CombArray front() { 1308 1315 static if(bufType == Buffer.RECYCLE) { 1309 1316 static if(!is(T == uint)) { … … 1326 1333 1327 1334 /// 1328 bool empty() const pure nothrow {1335 @property bool empty() const pure nothrow { 1329 1336 return length == 0; 1330 1337 } 1331 1338 1332 1339 /// 1333 size_t length() const pure nothrow {1340 @property size_t length() const pure nothrow { 1334 1341 return _length; 1342 } 1343 1344 /// 1345 @property typeof(this) save() { 1346 auto ret = this; 1347 ret.pos = (pos[0..R].dup).ptr; 1348 1349 if(chosen !is null) { 1350 ret.chosen = (chosen[0..R].dup).ptr; 1351 } 1352 1353 return ret; 1335 1354 } 1336 1355 } … … 1491 1510 } 1492 1511 1493 real front() {1512 @property real front() { 1494 1513 return _front; 1495 1514 } … … 1517 1536 } 1518 1537 1519 bool empty() {1538 @property bool empty() { 1520 1539 return inputRange.empty; 1521 1540 } trunk/cor.d
r209 r211 140 140 uint num; 141 141 uint upTo; 142 uint front() {142 @property size_t front() { 143 143 return num; 144 144 } … … 146 146 num++; 147 147 } 148 bool empty() {148 @property bool empty() { 149 149 return num >= upTo; 150 150 } … … 409 409 uint num; 410 410 uint upTo; 411 uint front() {411 @property size_t front() { 412 412 return num; 413 413 } … … 415 415 num++; 416 416 } 417 bool empty() {417 @property bool empty() { 418 418 return num >= upTo; 419 419 } … … 703 703 uint num; 704 704 uint upTo; 705 uint front() {705 @property size_t front() { 706 706 return num; 707 707 } … … 709 709 num++; 710 710 } 711 bool empty() {711 @property bool empty() { 712 712 return num >= upTo; 713 713 } trunk/infotheory.d
r209 r211 142 142 } 143 143 144 /**Iterate over a set of ranges in lockstep and return an ObsEnt,144 /**Iterate over a set of ranges by value in lockstep and return an ObsEnt, 145 145 * which is used internally by entropy functions on each iteration.*/ 146 146 struct Joint(T...) { 147 147 T _jointRanges; 148 148 149 ObsEnt!(ElementsTuple!(T)) front() {149 @property ObsEnt!(ElementsTuple!(T)) front() { 150 150 alias ElementsTuple!(T) E; 151 151 alias ObsEnt!(E) rt; … … 163 163 } 164 164 165 bool empty() {165 @property bool empty() { 166 166 foreach(elem; _jointRanges) { 167 167 if(elem.empty) { … … 173 173 174 174 static if(T.length > 0 && allSatisfy!(dstats.base.hasLength, T)) { 175 uint length() {176 uint ret = uint.max;175 @property size_t length() { 176 size_t ret = size_t.max; 177 177 foreach(range; _jointRanges) { 178 178 auto len = range.length; trunk/random.d
r209 r211 183 183 } 184 184 185 typeof(randFun(args)) front() {185 @property typeof(randFun(args)) front() { 186 186 return frontElem; 187 187 } … … 202 202 } 203 203 204 typeof(this) save() @property{204 @property typeof(this) save() { 205 205 return this; 206 206 } trunk/regress.d
r209 r211 63 63 } 64 64 65 double front() const pure nothrow {65 @property double front() const pure nothrow { 66 66 return cache; 67 67 } … … 74 74 } 75 75 76 typeof(this) save() @property{76 @property typeof(this) save() { 77 77 return this; 78 78 } 79 79 80 bool empty() @property{80 @property bool empty() { 81 81 return range.empty; 82 82 } … … 277 277 size_t i = 0; 278 278 foreach(elem; X) { 279 double frnt = elem.front ();279 double frnt = elem.front; 280 280 sum += frnt * betas[i]; 281 281 i++; … … 309 309 } 310 310 311 double front() const pure nothrow {311 @property double front() const pure nothrow { 312 312 return residual; 313 313 } … … 329 329 } 330 330 331 bool empty() const pure nothrow {331 @property bool empty() const pure nothrow { 332 332 return _empty; 333 333 } 334 334 335 typeof(this) save() @property{335 @property typeof(this) save() { 336 336 auto ret = this; 337 337 ret.Y = ret.Y.save; … … 512 512 double residual = residuals.front; 513 513 S += residual * residual; 514 double Yfront = residuals.Y.front ();514 double Yfront = residuals.Y.front; 515 515 double predicted = Yfront - residual; 516 516 R2Calc.put(predicted, Yfront); trunk/summary.d
r207 r211 152 152 uint num; 153 153 uint upTo; 154 uint front() {154 @property size_t front() { 155 155 return num; 156 156 } … … 158 158 num++; 159 159 } 160 bool empty() {160 @property bool empty() { 161 161 return num >= upTo; 162 162 } … … 1098 1098 1099 1099 /// 1100 double front() {1100 @property double front() { 1101 1101 return z(range.front); 1102 1102 } … … 1108 1108 1109 1109 /// 1110 bool empty() {1110 @property bool empty() { 1111 1111 return range.empty; 1112 } 1113 1114 static if(isForwardRange!(T)) { 1115 /// 1116 @property typeof(this) save() { 1117 auto ret = this; 1118 ret.range = range.save; 1119 return ret; 1120 } 1112 1121 } 1113 1122 … … 1121 1130 static if(isBidirectionalRange!(T)) { 1122 1131 /// 1123 double back() {1132 @property double back() { 1124 1133 return z(range.back); 1125 1134 } … … 1133 1142 static if(dstats.base.hasLength!(T)) { 1134 1143 /// 1135 size_t length() {1144 @property size_t length() { 1136 1145 return range.length; 1137 1146 }
