mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Rename Range::overlap to Range::overlaps
This commit is contained in:
parent
c48063dec7
commit
9e1e604108
7 changed files with 40 additions and 40 deletions
|
@ -1,6 +1,6 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2015 - 2016, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2015 - 2018, Thomas Lauf, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -113,7 +113,7 @@ std::vector <Range> Exclusion::ranges (const Range& range) const
|
|||
Datetime end (start);
|
||||
++end;
|
||||
Range all_day (start, end);
|
||||
if (range.overlap (all_day))
|
||||
if (range.overlaps (all_day))
|
||||
results.push_back (all_day);
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ std::vector <Range> Exclusion::ranges (const Range& range) const
|
|||
for (unsigned int block = 2; block < _tokens.size (); ++block)
|
||||
{
|
||||
auto r = rangeFromTimeBlock (_tokens[block], start, end);
|
||||
if (myRange.overlap (r))
|
||||
if (myRange.overlaps (r))
|
||||
results.push_back (r);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ bool Range::contains (const Datetime &datetime) const
|
|||
// H [...
|
||||
// I [...
|
||||
//
|
||||
bool Range::overlap (const Range& other) const
|
||||
bool Range::overlaps (const Range &other) const
|
||||
{
|
||||
if (! is_started () || ! other.is_started ())
|
||||
return false;
|
||||
|
@ -202,7 +202,7 @@ bool Range::endsWithin (const Range& other) const
|
|||
//
|
||||
Range Range::intersect (const Range& other) const
|
||||
{
|
||||
if (overlap (other))
|
||||
if (overlaps (other))
|
||||
{
|
||||
// Intersection is choosing the later of the two starts, and the earlier of
|
||||
// the two ends, provided the two ranges overlap.
|
||||
|
@ -237,7 +237,7 @@ Range Range::intersect (const Range& other) const
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Range::intersects (const Range &other) const
|
||||
{
|
||||
if (overlap (other)) {
|
||||
if (overlaps (other)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -313,7 +313,7 @@ std::vector <Range> Range::subtract (const Range& other) const
|
|||
{
|
||||
std::vector <Range> results;
|
||||
|
||||
if (overlap (other))
|
||||
if (overlaps (other))
|
||||
{
|
||||
if (start < other.start)
|
||||
{
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
|
||||
bool contains (const Datetime&) const;
|
||||
|
||||
bool overlap (const Range&) const;
|
||||
bool overlaps (const Range &) const;
|
||||
bool encloses (const Range&) const;
|
||||
bool startsWithin (const Range &) const;
|
||||
bool endsWithin (const Range &) const;
|
||||
|
|
|
@ -252,7 +252,7 @@ static void determineHourRange (
|
|||
|
||||
for (auto& track : tracked)
|
||||
{
|
||||
if (day_range.overlap (track.range))
|
||||
if (day_range.overlaps (track.range))
|
||||
{
|
||||
Interval clipped = clip (track, day_range);
|
||||
if (track.range.is_open ())
|
||||
|
@ -475,7 +475,7 @@ static void renderExclusionBlocks (
|
|||
|
||||
for (auto& exc : excluded)
|
||||
{
|
||||
if (exc.overlap (r))
|
||||
if (exc.overlaps (r))
|
||||
{
|
||||
// Determine which of the character blocks included.
|
||||
auto sub_hour = exc.intersect (r);
|
||||
|
@ -521,7 +521,7 @@ static void renderInterval (
|
|||
|
||||
// Ignore any track that doesn't overlap with day.
|
||||
auto day_range = getFullDay (day);
|
||||
if (! day_range.overlap (track.range) ||
|
||||
if (!day_range.overlaps (track.range) ||
|
||||
(track.range.is_open () && day > now))
|
||||
return;
|
||||
|
||||
|
@ -640,7 +640,7 @@ static std::string renderSummary (
|
|||
{
|
||||
time_t total_unavailable = 0;
|
||||
for (auto& exclusion : exclusions)
|
||||
if (filter.range.overlap (exclusion))
|
||||
if (filter.range.overlaps (exclusion))
|
||||
total_unavailable += filter.range.intersect (exclusion).total ();
|
||||
|
||||
time_t total_worked = 0;
|
||||
|
@ -648,7 +648,7 @@ static std::string renderSummary (
|
|||
{
|
||||
for (auto& interval : tracked)
|
||||
{
|
||||
if (filter.range.overlap (interval.range))
|
||||
if (filter.range.overlaps (interval.range))
|
||||
{
|
||||
Interval clipped = clip (interval, filter.range);
|
||||
if (interval.range.is_open ())
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2015 - 2016, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2015 - 2018, Thomas Lauf, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -429,7 +429,7 @@ std::vector <Range> merge (
|
|||
int merges = 0;
|
||||
for (unsigned int i = 0; i < sorted.size (); ++i)
|
||||
{
|
||||
if (cursor && sorted[cursor - 1].overlap (sorted[i]))
|
||||
if (cursor && sorted[cursor - 1].overlaps (sorted[i]))
|
||||
{
|
||||
sorted[cursor - 1] = sorted[cursor - 1].combine (sorted[i]);
|
||||
++merges;
|
||||
|
@ -457,11 +457,11 @@ std::vector <Range> addRanges (
|
|||
std::vector <Range> results;
|
||||
|
||||
for (auto& range : ranges)
|
||||
if (limits.overlap (range))
|
||||
if (limits.overlaps (range))
|
||||
results.push_back (range);
|
||||
|
||||
for (auto& addition : additions)
|
||||
if (limits.overlap (addition))
|
||||
if (limits.overlaps (addition))
|
||||
results.push_back (addition);
|
||||
|
||||
return results;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2015 - 2016, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2015 - 2018, Thomas Lauf, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -456,7 +456,7 @@ std::vector <Interval> getOverlaps (
|
|||
|
||||
std::vector <Interval> overlaps;
|
||||
for (auto& track : tracked)
|
||||
if (interval.range.overlap (track.range))
|
||||
if (interval.range.overlaps (track.range))
|
||||
overlaps.push_back (track);
|
||||
|
||||
return overlaps;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2015 - 2018, Paul Beckingham, Federico Hernandez.
|
||||
// Copyright 2015 - 2018, Thomas Lauf, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -56,7 +56,7 @@ int main (int, char**)
|
|||
// this [--------)
|
||||
// A [--------)
|
||||
// B [--------)
|
||||
// C [----|
|
||||
// C [----)
|
||||
// D [--------)
|
||||
// E [--------)
|
||||
// F [-------------)
|
||||
|
@ -75,15 +75,15 @@ int main (int, char**)
|
|||
Range testH; testH.start = Datetime (2016, 6, 15);
|
||||
Range testI; testI.start = Datetime (2016, 7, 15);
|
||||
|
||||
t.notok (refClosed.overlap (testA), "Range: ! refClosed.overlap(testA)");
|
||||
t.ok (refClosed.overlap (testB), "Range: refClosed.overlap(testB)");
|
||||
t.ok (refClosed.overlap (testC), "Range: refClosed.overlap(testC)");
|
||||
t.ok (refClosed.overlap (testD), "Range: refClosed.overlap(testD)");
|
||||
t.notok (refClosed.overlap (testE), "Range: ! refClosed.overlap(testE)");
|
||||
t.ok (refClosed.overlap (testF), "Range: refClosed.overlap(testF)");
|
||||
t.ok (refClosed.overlap (testG), "Range: refClosed.overlap(testG)");
|
||||
t.ok (refClosed.overlap (testH), "Range: refClosed.overlap(testH)");
|
||||
t.notok (refClosed.overlap (testI), "Range: ! refClosed.overlap(testI)");
|
||||
t.notok (refClosed.overlaps (testA), "Range: ! refClosed.overlaps(testA)");
|
||||
t.ok (refClosed.overlaps (testB), "Range: refClosed.overlaps(testB)");
|
||||
t.ok (refClosed.overlaps (testC), "Range: refClosed.overlaps(testC)");
|
||||
t.ok (refClosed.overlaps (testD), "Range: refClosed.overlaps(testD)");
|
||||
t.notok (refClosed.overlaps (testE), "Range: ! refClosed.overlaps(testE)");
|
||||
t.ok (refClosed.overlaps (testF), "Range: refClosed.overlaps(testF)");
|
||||
t.ok (refClosed.overlaps (testG), "Range: refClosed.overlaps(testG)");
|
||||
t.ok (refClosed.overlaps (testH), "Range: refClosed.overlaps(testH)");
|
||||
t.notok (refClosed.overlaps (testI), "Range: ! refClosed.overlaps(testI)");
|
||||
|
||||
// this [...
|
||||
// A [--------)
|
||||
|
@ -97,15 +97,15 @@ int main (int, char**)
|
|||
// I [...
|
||||
Range refOpen (Datetime (2016, 6, 1), Datetime (0));
|
||||
|
||||
t.notok (refOpen.overlap (testA), "Range: ! refOpen.overlap(testA)");
|
||||
t.ok (refOpen.overlap (testB), "Range: refOpen.overlap(testB)");
|
||||
t.ok (refOpen.overlap (testC), "Range: refOpen.overlap(testC)");
|
||||
t.ok (refOpen.overlap (testD), "Range: refOpen.overlap(testD)");
|
||||
t.ok (refOpen.overlap (testE), "Range: refOpen.overlap(testE)");
|
||||
t.ok (refOpen.overlap (testF), "Range: refOpen.overlap(testF)");
|
||||
t.ok (refOpen.overlap (testG), "Range: refOpen.overlap(testG)");
|
||||
t.ok (refOpen.overlap (testH), "Range: refOpen.overlap(testH)");
|
||||
t.ok (refOpen.overlap (testI), "Range: refOpen.overlap(testI)");
|
||||
t.notok (refOpen.overlaps (testA), "Range: ! refOpen.overlaps(testA)");
|
||||
t.ok (refOpen.overlaps (testB), "Range: refOpen.overlaps(testB)");
|
||||
t.ok (refOpen.overlaps (testC), "Range: refOpen.overlaps(testC)");
|
||||
t.ok (refOpen.overlaps (testD), "Range: refOpen.overlaps(testD)");
|
||||
t.ok (refOpen.overlaps (testE), "Range: refOpen.overlaps(testE)");
|
||||
t.ok (refOpen.overlaps (testF), "Range: refOpen.overlaps(testF)");
|
||||
t.ok (refOpen.overlaps (testG), "Range: refOpen.overlaps(testG)");
|
||||
t.ok (refOpen.overlaps (testH), "Range: refOpen.overlaps(testH)");
|
||||
t.ok (refOpen.overlaps (testI), "Range: refOpen.overlaps(testI)");
|
||||
|
||||
// this [--------)
|
||||
// A [--------)
|
||||
|
@ -245,7 +245,7 @@ int main (int, char**)
|
|||
// Adjacent ranges.
|
||||
Range left (Datetime ("20160425T110000"), Datetime ("20160425T120000"));
|
||||
Range right (Datetime ("20160425T120000"), Datetime ("20160425T130000"));
|
||||
t.notok (left.overlap (right), "Range: left (11am - 12pm) does not overlap with right (12pm - 1pm)");
|
||||
t.notok (left.overlaps (right), "Range: left (11am - 12pm) does not overlaps with right (12pm - 1pm)");
|
||||
|
||||
auto intersection = left.intersect (right);
|
||||
t.ok (intersection.start.toEpoch () == 0, "Range: adjacent ranges do not intersect");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue