mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Code Cleanup
- Removed unused util.cpp compressIds function.
This commit is contained in:
parent
dd6399aba7
commit
4f54578241
2 changed files with 0 additions and 56 deletions
55
src/util.cpp
55
src/util.cpp
|
@ -267,61 +267,6 @@ int flock (int fd, int operation)
|
|||
}
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// The vector must be sorted first. This is a modified version of the run-
|
||||
// length encoding algorithm.
|
||||
//
|
||||
// This function converts the vector:
|
||||
//
|
||||
// [1, 3, 4, 6, 7, 8, 9, 11]
|
||||
//
|
||||
// to ths string:
|
||||
//
|
||||
// 1,3-4,6-9,11
|
||||
//
|
||||
std::string compressIds (const std::vector <int>& ids)
|
||||
{
|
||||
std::stringstream result;
|
||||
|
||||
int range_start = 0;
|
||||
int range_end = 0;
|
||||
|
||||
for (unsigned int i = 0; i < ids.size (); ++i)
|
||||
{
|
||||
if (i + 1 == ids.size ())
|
||||
{
|
||||
if (result.str ().length ())
|
||||
result << ",";
|
||||
|
||||
if (range_start < range_end)
|
||||
result << ids[range_start] << "-" << ids[range_end];
|
||||
else
|
||||
result << ids[range_start];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ids[range_end] + 1 == ids[i + 1])
|
||||
{
|
||||
++range_end;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (result.str ().length ())
|
||||
result << ",";
|
||||
|
||||
if (range_start < range_end)
|
||||
result << ids[range_start] << "-" << ids[range_end];
|
||||
else
|
||||
result << ids[range_start];
|
||||
|
||||
range_start = range_end = i + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result.str ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void combine (std::vector <int>& dest, const std::vector <int>& source)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue