-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterval.cpp
More file actions
80 lines (62 loc) · 1.89 KB
/
Copy pathInterval.cpp
File metadata and controls
80 lines (62 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*****************************************************************
* Interval.cpp
*
* CIntervalSet represents the collection of mempory ranges
* used by textures within TMU memory.
*
* Initial development by Paul Gardiner
*
* This software is released under the GNU Library or Lesser
* General Public License (LGPL)
*
****************************************************************/
#include "StdAfx.h"
#include "Interval.h"
CIntervalSet::CIntervalSet()
{
m_imax = 0;
}
CIntervalSet::~CIntervalSet()
{
Clear();
}
void CIntervalSet::Clear()
{
IntervalStore::iterator iter;
for(iter = m_map.begin(); iter != m_map.end(); iter++)
delete iter->second;
m_map.clear();
}
void CIntervalSet::Add(CInterval *ivl)
{
FxU32 size = ivl->limit - ivl->start;
if(size > m_imax)
m_imax = size;
m_map[ivl->start] = ivl;
}
CInterval *CIntervalSet::Find(FxU32 start)
{
IntervalStore::iterator iter;
iter = m_map.find(start);
return (iter == m_map.end()) ? NULL : iter->second;
}
void CIntervalSet::Wipe(CInterval *ivl)
{
FxU32 start;
IntervalStore::iterator iter, iter2;
/* Work out how far below this interval
* we need to look to check for overlaps */
start = (ivl->start > m_imax)
? ivl->start - m_imax
: 0;
/* Look for first interval that ends past
* the start of the test interval */
for(iter = m_map.lower_bound(start); iter != m_map.end() && iter->second->limit <= ivl->start; iter++)
;
/* While we have stored intervals that don't
* start past the end of the test interval,
* destroy and remove them */
for(iter2 = iter; iter2 != m_map.end() && iter2->second->start < ivl->limit; iter2++)
delete iter2->second;
m_map.erase(iter, iter2);
}