Changeset 2730 for trunk/src/BufferedBisectionLocator.cpp
- Timestamp:
- 01/16/13 16:00:28 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/BufferedBisectionLocator.cpp
r2727 r2730 15 15 16 16 namespace asap { 17 BufferedBisectionLocator::BufferedBisectionLocator() 18 : Locator(), 19 prev_(0) 20 {} 17 21 18 BufferedBisectionLocator::BufferedBisectionLocator(double *v, unsigned int n) 19 : Locator(v, n), 22 BufferedBisectionLocator::BufferedBisectionLocator(double *v, unsigned int n, 23 bool copystorage) 24 : Locator(v, n, copystorage), 20 25 prev_(0) 21 26 {} … … 28 33 if (n_ == 1) 29 34 return 0; 30 bool ascending = (x_[n_-1] >= x_[0]); 31 if (ascending) { 35 36 unsigned int jl = 0; 37 unsigned int ju = n_; 38 if (ascending_) { 39 // ascending order 32 40 if (x <= x_[0]) 33 41 return 0; … … 35 43 return n_; 36 44 37 unsigned int jl = 0; 38 unsigned int ju = n_; 39 unsigned int jm; 45 if (x < x_[prev_]) { 46 ju = bisection(x, jl, prev_); 47 } 48 else { 49 ju = bisection(x, prev_, ju); 50 } 40 51 41 if (x < x_[prev_]) {42 ju = prev_;43 prev_ = 0;44 }45 else46 jl = prev_;47 48 while (ju - jl > 1) {49 jm = (ju + jl) >> 1;50 if (x > x_[jm])51 jl = jm;52 else53 ju = jm;54 }55 prev_ = jl;56 return ju;57 52 } 58 53 else { 54 // descending order 59 55 if (x >= x_[0]) 60 56 return 0; … … 62 58 return n_; 63 59 64 unsigned int jl = 0; 65 unsigned int ju = n_; 66 unsigned int jm; 60 if (x > x_[prev_]) { 61 ju = bisection(x, jl, prev_); 62 } 63 else { 64 ju = bisection(x, prev_, ju); 65 } 66 } 67 67 68 if (x > x_[prev_]) { 69 ju = prev_; 70 prev_ = 0; 71 } 72 else 73 jl = prev_; 74 75 while (ju - jl > 1) { 76 jm = (ju + jl) >> 1; 77 if (x < x_[jm]) 78 jl = jm; 79 else 80 ju = jm; 81 } 82 prev_ = jl; 83 return ju; 84 } 68 prev_ = (ju > 0) ? ju - 1 : 0; 69 return ju; 85 70 } 86 71
Note: See TracChangeset
for help on using the changeset viewer.