~ubuntu-branches/ubuntu/hardy/codeblocks/hardy-backports

« back to all changes in this revision

Viewing changes to src/plugins/contrib/wxSmithContribItems/wxthings/wxthings/src/range.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michael Casadevall
  • Date: 2008-07-17 04:39:23 UTC
  • Revision ID: james.westby@ubuntu.com-20080717043923-gmsy5cwkdjswghkm
Tags: upstream-8.02
ImportĀ upstreamĀ versionĀ 8.02

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/////////////////////////////////////////////////////////////////////////////
 
2
// Name:        range.cpp
 
3
// Purpose:     Simple min-max range class and associated selection array class
 
4
// Author:      John Labenski
 
5
// Created:     12/01/2000
 
6
// Copyright:   (c) John Labenski 2004
 
7
// Licence:     wxWidgets
 
8
/////////////////////////////////////////////////////////////////////////////
 
9
 
 
10
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
 
11
    #pragma implementation "range.h"
 
12
#endif
 
13
 
 
14
// For compilers that support precompilation, includes "wx.h".
 
15
#include "wx/wxprec.h"
 
16
 
 
17
#ifdef __BORLANDC__
 
18
    #pragma hdrstop
 
19
#endif
 
20
 
 
21
#ifndef WX_PRECOMP
 
22
    #include "wx/utils.h"
 
23
#endif // WX_PRECOMP
 
24
 
 
25
#include "wx/things/range.h"
 
26
#include <stdio.h>
 
27
 
 
28
const wxRangeInt wxEmptyRangeInt(0, -1);
 
29
const wxRangeDouble wxEmptyRangeDouble(0, -1);
 
30
 
 
31
#include "wx/arrimpl.cpp"
 
32
WX_DEFINE_OBJARRAY(wxArrayRangeInt);
 
33
WX_DEFINE_OBJARRAY(wxArrayRangeDouble);
 
34
WX_DEFINE_OBJARRAY(wxArrayRangeIntSelection);
 
35
WX_DEFINE_OBJARRAY(wxArrayRangeDoubleSelection);
 
36
 
 
37
 
 
38
// set this if you want to double check that that ranges are really working
 
39
//#define CHECK_RANGES
 
40
 
 
41
//=============================================================================
 
42
// wxRangeInt
 
43
//=============================================================================
 
44
 
 
45
bool wxRangeInt::Combine(int i, bool only_if_touching)
 
46
{
 
47
    if (only_if_touching)
 
48
    {
 
49
        if      (i == m_min-1) { m_min--; return true; }
 
50
        else if (i == m_max+1) { m_max++; return true; }
 
51
    }
 
52
    else
 
53
    {
 
54
        if      (i < m_min) { m_min = i; return true; }
 
55
        else if (i > m_max) { m_max = i; return true; }
 
56
    }
 
57
    return false;
 
58
}
 
59
 
 
60
bool wxRangeInt::Combine( const wxRangeInt &r, bool only_if_touching )
 
61
{
 
62
    if (only_if_touching)
 
63
    {
 
64
        if (Touches(r))
 
65
        {
 
66
            *this+=r;
 
67
            return true;
 
68
        }
 
69
    }
 
70
    else
 
71
    {
 
72
        bool added = false;
 
73
        if (r.m_min < m_min) { m_min = r.m_min; added = true; }
 
74
        if (r.m_max > m_max) { m_max = r.m_max; added = true; }
 
75
        return added;
 
76
    }
 
77
    return false;
 
78
}
 
79
 
 
80
bool wxRangeInt::Delete( const wxRangeInt &r, wxRangeInt *right )
 
81
{
 
82
    if (!Contains(r))
 
83
        return false;
 
84
 
 
85
    if (right) *right = wxEmptyRangeInt;
 
86
 
 
87
    if (r.m_min <= m_min)
 
88
    {
 
89
        if (r.m_max >= m_max)
 
90
        {
 
91
            *this = wxEmptyRangeInt;
 
92
            return true;
 
93
        }
 
94
 
 
95
        m_min = r.m_max + 1;
 
96
        return true;
 
97
    }
 
98
 
 
99
    if (r.m_max >= m_max)
 
100
    {
 
101
        m_max = r.m_min - 1;
 
102
        return true;
 
103
    }
 
104
 
 
105
    if (right)
 
106
        *right = wxRangeInt(r.m_max + 1, m_max);
 
107
 
 
108
    m_max = r.m_min - 1;
 
109
    return true;
 
110
}
 
111
 
 
112
//=============================================================================
 
113
// wxRangeIntSelection
 
114
//=============================================================================
 
115
const wxRangeInt& wxRangeIntSelection::GetRange( int index ) const
 
116
{
 
117
    wxCHECK_MSG((index>=0) && (index<int(m_ranges.GetCount())), wxEmptyRangeInt, wxT("Invalid index"));
 
118
    return m_ranges[index];
 
119
}
 
120
 
 
121
wxRangeInt wxRangeIntSelection::GetBoundingRange() const
 
122
{
 
123
    if (int(m_ranges.GetCount()) < 1) return wxEmptyRangeInt;
 
124
    return wxRangeInt(m_ranges[0].m_min, m_ranges[m_ranges.GetCount()-1].m_max);
 
125
}
 
126
 
 
127
int wxRangeIntSelection::Index( int i ) const
 
128
{
 
129
    int count = m_ranges.GetCount();
 
130
    if (count < 1) return wxNOT_FOUND;
 
131
 
 
132
    if (i < m_ranges[0].m_min) return wxNOT_FOUND;
 
133
    if (i > m_ranges[count-1].m_max) return wxNOT_FOUND;
 
134
 
 
135
    // Binary search
 
136
    int res, tmp, lo = 0, hi = count;
 
137
 
 
138
    while ( lo < hi )
 
139
    {
 
140
        tmp = (lo + hi)/2;
 
141
        res = m_ranges[tmp].Position(i);
 
142
 
 
143
        if (res == 0)
 
144
            return tmp;
 
145
        else if ( res < 0 )
 
146
            hi = tmp;
 
147
        else //if ( res > 0 )
 
148
            lo = tmp + 1;
 
149
    }
 
150
 
 
151
    return wxNOT_FOUND;
 
152
}
 
153
 
 
154
int wxRangeIntSelection::Index( const wxRangeInt &r ) const
 
155
{
 
156
    register int i, count = m_ranges.GetCount();
 
157
    for (i=0; i<count; i++) if (m_ranges[i].Contains(r)) return i;
 
158
    return wxNOT_FOUND;
 
159
}
 
160
 
 
161
int wxRangeIntSelection::NearestIndex( int i ) const
 
162
{
 
163
    int count = m_ranges.GetCount();
 
164
    if (count < 1) return -1;
 
165
 
 
166
    if (i < m_ranges[0].m_min) return -1;
 
167
    if (i > m_ranges[count-1].m_max) return count;
 
168
 
 
169
    // Binary search
 
170
    int res, tmp, lo = 0, hi = count;
 
171
 
 
172
    while ( lo < hi )
 
173
    {
 
174
        tmp = (lo + hi)/2;
 
175
        res = m_ranges[tmp].Position(i);
 
176
 
 
177
        if ( res == 0 )
 
178
            return tmp;
 
179
        else if ((i >= m_ranges[tmp].m_max) && (i < m_ranges[wxMin(tmp+1, count-1)].m_min))
 
180
            return tmp;
 
181
        else if ( res < 0 )
 
182
            hi = tmp;
 
183
        else //if ( res > 0 )
 
184
            lo = tmp + 1;
 
185
    }
 
186
 
 
187
    // oops shouldn't get here
 
188
    wxCHECK_MSG(0, -1, wxT("Error calculating NearestIndex in wxRangeIntSelection"));
 
189
}
 
190
 
 
191
int wxRangeIntSelection::GetItemCount() const
 
192
{
 
193
    register int i, items = 0, count = m_ranges.GetCount();
 
194
    for (i=0; i<count; i++) items += m_ranges[i].GetRange();
 
195
    return items;
 
196
}
 
197
 
 
198
bool wxRangeIntSelection::DeselectRange(const wxRangeInt &range)
 
199
{
 
200
    wxCHECK_MSG(!range.IsEmpty(), false, wxT("Invalid Selection Range") );
 
201
 
 
202
    bool done = false;
 
203
    int i, count = m_ranges.GetCount();
 
204
    int nearest = count > 0 ? NearestIndex(range.m_min) : -1;
 
205
 
 
206
    if ((nearest < 0) || (nearest == count))
 
207
        return false;
 
208
 
 
209
    wxRangeInt r;
 
210
    for (i=nearest; i<int(m_ranges.GetCount()); i++)
 
211
    {
 
212
        if (range.m_max < m_ranges[i].m_min)
 
213
            break;
 
214
        else if (m_ranges[i].Delete(range, &r))
 
215
        {
 
216
            if (m_ranges[i].IsEmpty())
 
217
            {
 
218
                m_ranges.RemoveAt(i);
 
219
                i = (i > 0) ? i-1 : -1;
 
220
            }
 
221
            else if (!r.IsEmpty())
 
222
                m_ranges.Insert(r, i+1);
 
223
 
 
224
            done = true;
 
225
        }
 
226
    }
 
227
 
 
228
    return done;
 
229
}
 
230
 
 
231
bool wxRangeIntSelection::SelectRange(const wxRangeInt &range)
 
232
{
 
233
    wxCHECK_MSG(!range.IsEmpty(), false, wxT("Invalid Selection Range") );
 
234
 
 
235
    // Try to find a range that includes this one and combine it, else insert it, else append it
 
236
    bool done = false;
 
237
    int i, count = m_ranges.GetCount();
 
238
    int nearest = count > 0 ? NearestIndex(range.m_min) : -1;
 
239
 
 
240
    if (nearest < 0)
 
241
    {
 
242
        if (!((count > 0) && m_ranges[0].Combine(range, true)))
 
243
            m_ranges.Insert(range, 0);
 
244
        return true;
 
245
    }
 
246
    else if (nearest == count)
 
247
    {
 
248
        if (!((count > 0) && m_ranges[count-1].Combine(range, true)))
 
249
            m_ranges.Add(range);
 
250
        return true;
 
251
    }
 
252
    else
 
253
    {
 
254
        if (m_ranges[nearest].Contains(range))
 
255
            return false;
 
256
 
 
257
        for (i=nearest; i<count; i++)
 
258
        {
 
259
            if (m_ranges[i].Combine(range, true))
 
260
            {
 
261
                done = true;
 
262
                break;
 
263
            }
 
264
            else if (range.m_max < m_ranges[i].m_min)
 
265
            {
 
266
                m_ranges.Insert(range, i);
 
267
                return true;
 
268
            }
 
269
        }
 
270
 
 
271
        count = m_ranges.GetCount();
 
272
        for (i=wxMax(nearest-1, 1); i<count; i++)
 
273
        {
 
274
            if (range.m_max+1 < m_ranges[i-1].m_min)
 
275
                break;
 
276
            else if (m_ranges[i-1].Combine(m_ranges[i], true))
 
277
            {
 
278
                m_ranges.RemoveAt(i);
 
279
                count--;
 
280
                i--;
 
281
            }
 
282
        }
 
283
    }
 
284
 
 
285
#ifdef CHECK_RANGES
 
286
    printf("Selecting ranges %d %d count %d\n", range.m_min, range.m_max, m_ranges.GetCount());
 
287
 
 
288
    for (i=1; i<int(m_ranges.GetCount()); i++)
 
289
    {
 
290
        if (m_ranges[i-1].Contains(m_ranges[i]))
 
291
            printf("Error in Selecting ranges %d %d, %d %d count %d\n", m_ranges[i-1].m_min, m_ranges[i-1].m_max, m_ranges[i].m_min, m_ranges[i].m_max, m_ranges.GetCount());
 
292
        if (m_ranges[i-1].Touches(m_ranges[i]))
 
293
            printf("Could have minimzed ranges %d %d, %d %d count %d\n", m_ranges[i-1].m_min, m_ranges[i-1].m_max, m_ranges[i].m_min, m_ranges[i].m_max, m_ranges.GetCount());
 
294
    }
 
295
    fflush(stdout);
 
296
#endif // CHECK_RANGES
 
297
 
 
298
    return done;
 
299
}
 
300
 
 
301
bool wxRangeIntSelection::BoundRanges(const wxRangeInt& range)
 
302
{
 
303
    wxCHECK_MSG(!range.IsEmpty(), false, wxT("Invalid Bounding Range") );
 
304
    int i, count = m_ranges.GetCount();
 
305
    bool done = false;
 
306
 
 
307
    for (i = 0; i < count; i++)
 
308
    {
 
309
        if (m_ranges[i].m_min >= range.m_min)
 
310
            break;
 
311
 
 
312
        if (m_ranges[i].m_max < range.m_min) // range is out of bounds
 
313
        {
 
314
            done = true;
 
315
            m_ranges.RemoveAt(i);
 
316
            count--;
 
317
            i--;
 
318
        }
 
319
        else
 
320
        {
 
321
            done = true;
 
322
            m_ranges[i].m_min = range.m_min;
 
323
            break;
 
324
        }
 
325
    }
 
326
 
 
327
    for (i = m_ranges.GetCount() - 1; i >= 0; i--)
 
328
    {
 
329
        if (m_ranges[i].m_max <= range.m_max)
 
330
            break;
 
331
 
 
332
        if (m_ranges[i].m_min > range.m_max) // range is out of bounds
 
333
        {
 
334
            done = true;
 
335
            m_ranges.RemoveAt(i);
 
336
        }
 
337
        else
 
338
        {
 
339
            done = true;
 
340
            m_ranges[i].m_max = range.m_max;
 
341
            break;
 
342
        }
 
343
    }
 
344
 
 
345
    return done;
 
346
}
 
347
 
 
348
//=============================================================================
 
349
// wxRangeDouble
 
350
//=============================================================================
 
351
 
 
352
bool wxRangeDouble::Combine(double i)
 
353
{
 
354
    if      (i < m_min) { m_min = i; return true; }
 
355
    else if (i > m_max) { m_max = i; return true; }
 
356
    return false;
 
357
}
 
358
 
 
359
bool wxRangeDouble::Combine( const wxRangeDouble &r, bool only_if_touching )
 
360
{
 
361
    if (only_if_touching)
 
362
    {
 
363
        if (Contains(r))
 
364
        {
 
365
            *this+=r;
 
366
            return true;
 
367
        }
 
368
    }
 
369
    else
 
370
    {
 
371
        bool added = false;
 
372
        if (r.m_min < m_min) { m_min = r.m_min; added = true; }
 
373
        if (r.m_max > m_max) { m_max = r.m_max; added = true; }
 
374
        return added;
 
375
    }
 
376
    return false;
 
377
}
 
378
 
 
379
bool wxRangeDouble::Delete( const wxRangeDouble &r, wxRangeDouble *right )
 
380
{
 
381
    if (!Contains(r))
 
382
        return false;
 
383
 
 
384
    if (right) *right = wxEmptyRangeDouble;
 
385
 
 
386
    if (r.m_min <= m_min)
 
387
    {
 
388
        if (r.m_max >= m_max)
 
389
        {
 
390
            *this = wxEmptyRangeDouble;
 
391
            return true;
 
392
        }
 
393
 
 
394
        m_min = r.m_max;
 
395
        return true;
 
396
    }
 
397
 
 
398
    if (r.m_max >= m_max)
 
399
    {
 
400
        m_max = r.m_min;
 
401
        return true;
 
402
    }
 
403
 
 
404
    if (right)
 
405
        *right = wxRangeDouble(r.m_max, m_max);
 
406
 
 
407
    m_max = r.m_min;
 
408
    return true;
 
409
}
 
410
 
 
411
//=============================================================================
 
412
// wxRangeDoubleSelection
 
413
//=============================================================================
 
414
const wxRangeDouble& wxRangeDoubleSelection::GetRange( int index ) const
 
415
{
 
416
    wxCHECK_MSG((index>=0) && (index<int(m_ranges.GetCount())), wxEmptyRangeDouble, wxT("Invalid index"));
 
417
    return m_ranges[index];
 
418
}
 
419
 
 
420
wxRangeDouble wxRangeDoubleSelection::GetBoundingRange() const
 
421
{
 
422
    if (int(m_ranges.GetCount()) < 1) return wxEmptyRangeDouble;
 
423
    return wxRangeDouble(m_ranges[0].m_min, m_ranges[m_ranges.GetCount()-1].m_max);
 
424
}
 
425
 
 
426
int wxRangeDoubleSelection::Index( wxDouble i ) const
 
427
{
 
428
    int count = m_ranges.GetCount();
 
429
    if (count < 1) return wxNOT_FOUND;
 
430
 
 
431
    if (i < m_ranges[0].m_min) return wxNOT_FOUND;
 
432
    if (i > m_ranges[count-1].m_max) return wxNOT_FOUND;
 
433
 
 
434
    // Binary search
 
435
    int res, tmp, lo = 0, hi = count;
 
436
 
 
437
    while ( lo < hi )
 
438
    {
 
439
        tmp = (lo + hi)/2;
 
440
        res = m_ranges[tmp].Position(i);
 
441
 
 
442
        if ( res == 0 )
 
443
            return tmp;
 
444
        else if ( res < 0 )
 
445
            hi = tmp;
 
446
        else //if ( res > 0 )
 
447
            lo = tmp + 1;
 
448
    }
 
449
 
 
450
    return wxNOT_FOUND;
 
451
 
 
452
/*
 
453
    for (register int j=0; j<count; j++)
 
454
    {
 
455
        if (m_ranges[j].Contains(i)) return j;
 
456
    }
 
457
*/
 
458
}
 
459
 
 
460
int wxRangeDoubleSelection::Index( const wxRangeDouble &r ) const
 
461
{
 
462
    register int i, count = m_ranges.GetCount();
 
463
    for (i=0; i<count; i++) if (m_ranges[i].Contains(r)) return i;
 
464
    return wxNOT_FOUND;
 
465
}
 
466
 
 
467
int wxRangeDoubleSelection::NearestIndex( wxDouble i ) const
 
468
{
 
469
    register int count = m_ranges.GetCount();
 
470
    if (count < 1) return -1;
 
471
 
 
472
    if (i < m_ranges[0].m_min) return -1;
 
473
    if (i > m_ranges[count-1].m_max) return count;
 
474
 
 
475
    // Binary search
 
476
    int res, tmp, lo = 0, hi = count;
 
477
 
 
478
    while ( lo < hi )
 
479
    {
 
480
        tmp = (lo + hi)/2;
 
481
        res = m_ranges[tmp].Position(i);
 
482
 
 
483
        if ( res == 0 )
 
484
            return tmp;
 
485
        else if ((i >= m_ranges[tmp].m_max) && (i < m_ranges[wxMin(tmp+1, count-1)].m_min))
 
486
            return tmp;
 
487
        else if ( res < 0 )
 
488
            hi = tmp;
 
489
        else //if ( res > 0 )
 
490
            lo = tmp + 1;
 
491
    }
 
492
 
 
493
    // oops shouldn't get here
 
494
    wxCHECK_MSG(0, -1, wxT("Error calculating NearestIndex in wxRangeDoubleSelection"));
 
495
}
 
496
 
 
497
bool wxRangeDoubleSelection::SelectRange(const wxRangeDouble &range)
 
498
{
 
499
    wxCHECK_MSG(!range.IsEmpty(), false, wxT("Invalid Selection Range") );
 
500
 
 
501
    // Try to find a range that includes this one and combine it, else insert it, else append it
 
502
    bool done = false;
 
503
    int i, count = m_ranges.GetCount();
 
504
    int nearest = count > 0 ? NearestIndex(range.m_min) : -1;
 
505
 
 
506
    if (nearest < 0)
 
507
    {
 
508
        if (!((count > 0) && m_ranges[0].Combine(range, true)))
 
509
            m_ranges.Insert(range, 0);
 
510
        return true;
 
511
    }
 
512
    else if (nearest == count)
 
513
    {
 
514
        if (!((count > 0) && m_ranges[count-1].Combine(range, true)))
 
515
            m_ranges.Add(range);
 
516
        return true;
 
517
    }
 
518
    else
 
519
    {
 
520
        if (m_ranges[nearest].Contains(range))
 
521
            return false;
 
522
 
 
523
        for (i=nearest; i<count; i++)
 
524
        {
 
525
            if (m_ranges[i].Combine(range, true))
 
526
            {
 
527
                done = true;
 
528
                break;
 
529
            }
 
530
            else if (range.m_max < m_ranges[i].m_min)
 
531
            {
 
532
                m_ranges.Insert(range, i);
 
533
                return true;
 
534
            }
 
535
        }
 
536
        for (i=wxMax(nearest-1, 1); i<int(m_ranges.GetCount()); i++)
 
537
        {
 
538
            if (range.m_max+1 < m_ranges[i-1].m_min)
 
539
                break;
 
540
            else if (m_ranges[i-1].Combine(m_ranges[i], true))
 
541
            {
 
542
                m_ranges.RemoveAt(i);
 
543
                i--;
 
544
            }
 
545
        }
 
546
    }
 
547
 
 
548
#ifdef CHECK_RANGES
 
549
    printf("Selecting ranges %g %g count %d\n", range.m_min, range.m_max, m_ranges.GetCount());
 
550
 
 
551
    for (i=1; i<int(m_ranges.GetCount()); i++)
 
552
    {
 
553
        if (m_ranges[i-1].Contains(m_ranges[i]))
 
554
            printf("Error in Selecting ranges %g %g, %g %g count %d\n", m_ranges[i-1].m_min, m_ranges[i-1].m_max, m_ranges[i].m_min, m_ranges[i].m_max, m_ranges.GetCount());
 
555
        //if (m_ranges[i-1].Touches(m_ranges[i]))
 
556
        //    printf("Could have minimzed ranges %g %g, %g %g count %d\n", m_ranges[i-1].m_min, m_ranges[i-1].m_max, m_ranges[i].m_min, m_ranges[i].m_max, m_ranges.GetCount());
 
557
    }
 
558
    fflush(stdout);
 
559
#endif // CHECK_RANGES
 
560
 
 
561
    return done;
 
562
}
 
563
 
 
564
bool wxRangeDoubleSelection::DeselectRange(const wxRangeDouble &range)
 
565
{
 
566
    wxCHECK_MSG(!range.IsEmpty(), false, wxT("Invalid Selection Range") );
 
567
 
 
568
    bool done = false;
 
569
    int i, count = m_ranges.GetCount();
 
570
    int nearest = count > 0 ? NearestIndex(range.m_min) : -1;
 
571
 
 
572
    if ((nearest < 0) || (nearest == count))
 
573
        return false;
 
574
 
 
575
    wxRangeDouble r;
 
576
    for (i=nearest; i<int(m_ranges.GetCount()); i++)
 
577
    {
 
578
        if (range.m_max < m_ranges[i].m_min)
 
579
            break;
 
580
        else if (m_ranges[i].Delete(range, &r))
 
581
        {
 
582
            if (m_ranges[i].IsEmpty())
 
583
            {
 
584
                m_ranges.RemoveAt(i);
 
585
                i = (i > 0) ? i-1 : -1;
 
586
            }
 
587
            else if (!r.IsEmpty())
 
588
                m_ranges.Insert(r, i+1);
 
589
 
 
590
            done = true;
 
591
        }
 
592
    }
 
593
 
 
594
    return done;
 
595
}
 
596
 
 
597
bool wxRangeDoubleSelection::BoundRanges(const wxRangeDouble& range)
 
598
{
 
599
    wxCHECK_MSG(!range.IsEmpty(), false, wxT("Invalid Bounding Range") );
 
600
    int i, count = m_ranges.GetCount();
 
601
    bool done = false;
 
602
 
 
603
    for (i = 0; i < count; i++)
 
604
    {
 
605
        if (m_ranges[i].m_min >= range.m_min)
 
606
            break;
 
607
 
 
608
        if (m_ranges[i].m_max < range.m_min) // range is out of bounds
 
609
        {
 
610
            done = true;
 
611
            m_ranges.RemoveAt(i);
 
612
            count--;
 
613
            i--;
 
614
        }
 
615
        else
 
616
        {
 
617
            done = true;
 
618
            m_ranges[i].m_min = range.m_min;
 
619
            break;
 
620
        }
 
621
    }
 
622
 
 
623
    for (i = m_ranges.GetCount() - 1; i >= 0; i--)
 
624
    {
 
625
        if (m_ranges[i].m_max <= range.m_max)
 
626
            break;
 
627
 
 
628
        if (m_ranges[i].m_min > range.m_max) // range is out of bounds
 
629
        {
 
630
            done = true;
 
631
            m_ranges.RemoveAt(i);
 
632
        }
 
633
        else
 
634
        {
 
635
            done = true;
 
636
            m_ranges[i].m_max = range.m_max;
 
637
            break;
 
638
        }
 
639
    }
 
640
 
 
641
    return done;
 
642
}