-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathMarkArea.cpp
More file actions
executable file
·56 lines (48 loc) · 1.2 KB
/
MarkArea.cpp
File metadata and controls
executable file
·56 lines (48 loc) · 1.2 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
/*-----------------------------------------------------------------------------
Lua Studio
Copyright (c) 1996-2008 Michal Kowalski
-----------------------------------------------------------------------------*/
#include "StdAfx.h"
#include "MarkArea.h"
void CMarkArea::SetEnd(int end)
{
ASSERT(start >= 0); // przed 'SetEnd' musi być wywołane 'SetStart'
ASSERT(end >= start); // błędne krańce przedziałów
if (end < start) // błędne krańce przedziałów?
return;
Pair pair= {start,end};
for (UINT i=0; i<n; i++)
{
if (arr[i].a > end || arr[i].b < start)
continue; // przedziały rozłączne
if (arr[i].a <= start)
if (arr[i].b >= end)
return; // nowa para mieści się w przedziale
else
{
arr[i].b = end; // przesunięcie końca przedziału
return;
}
else if (arr[i].b <= end)
{
arr[i].a = start; // przesunięcie początku przedziału
return;
}
else
{
arr[i].a = start; // poszerzenie całego przedziału
arr[i].b = end;
return;
}
}
arr.SetAtGrow(n,pair);
n++;
}
bool CMarkArea::GetPartition(UINT no, int &a, int &b)
{
if (no >= n)
return FALSE;
a = arr[no].a;
b = arr[no].b;
return true;
}