aboutsummaryrefslogtreecommitdiff
path: root/angleset.cpp
diff options
context:
space:
mode:
authorAndreas Grois <andreas.grois@jku.at>2015-11-27 11:02:12 +0100
committerAndreas Grois <andreas.grois@jku.at>2015-11-27 11:02:12 +0100
commit77618b3511ee5edb6509902126293a084f9767bf (patch)
treeab47be7697faca724cce06f074209ceed77840dc /angleset.cpp
parentfc46d20e8411fe4b67269733f69d8a9dded4a42f (diff)
Angleset: Change add behaviour to not run combine()
The most often used command for angleset in this tool is the add function. If at the end of every add the combine() function is being called, a lot of CPU time is wasted. Add now doesn't call combine(), and marks the angleset as dirty instead. All functions that require a clean angleset now check if it's dirty, and if yes call combine().
Diffstat (limited to 'angleset.cpp')
-rw-r--r--angleset.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/angleset.cpp b/angleset.cpp
index fc759b8..24d5b62 100644
--- a/angleset.cpp
+++ b/angleset.cpp
@@ -114,9 +114,10 @@ void angleset::add(const anglerange &value)
//this means: we *should not reuse* this function for adding anglesets.
if(!value.isempty())
{
+ consistent=false;
storage.push_back(value);
storage.back().setsorttype(anglerange::SRT_LOWER);
- combine();
+ //combine();
}
}
@@ -125,14 +126,16 @@ void angleset::add(const angleset &value)
storage.reserve(storage.size()+value.storage.size());
storage.insert(storage.end(),value.storage.begin(),value.storage.end());
//if value is a valid angleset, sort order is set to SRT_LOWER for all fields.
- combine();
+ consistent=false;
+ //combine();
}
void angleset::add(const double &lower, const double &upper)
{
storage.push_back(anglerange(lower,upper));
storage.back().setsorttype(anglerange::SRT_LOWER);
- combine();
+ consistent=false;
+ //combine();
}
@@ -164,25 +167,34 @@ angleset angleset::overlap(const angleset &other)
retval.add(overlap(i));
}
);
+ if(!other.consistent)
+ retval.combine();
return(retval);
}
std::vector<anglerange> angleset::getranges()
{
+ if(!consistent)
+ combine();
return storage;
}
const std::vector<anglerange>& angleset::getrangesref()
{
+ if(!consistent)
+ combine();
return storage;
}
void angleset::clear()
{
storage.clear();
+ consistent=true;
}
void angleset::sort()
{
+ if(!consistent)
+ combine();
std::sort(storage.begin(),storage.end());
}