/usr/include/stxxl/bits/stream/unique.h is in libstxxl-dev 1.4.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | /***************************************************************************
* include/stxxl/bits/stream/unique.h
*
* Part of the STXXL. See http://stxxl.sourceforge.net
*
* Copyright (C) 2003-2005 Roman Dementiev <dementiev@mpi-sb.mpg.de>
* Copyright (C) 2010 Andreas Beckmann <beckmann@cs.uni-frankfurt.de>
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
**************************************************************************/
#ifndef STXXL_STREAM_UNIQUE_HEADER
#define STXXL_STREAM_UNIQUE_HEADER
#include <stxxl/bits/namespace.h>
STXXL_BEGIN_NAMESPACE
//! Stream package subnamespace.
namespace stream {
////////////////////////////////////////////////////////////////////////
// UNIQUE //
////////////////////////////////////////////////////////////////////////
struct dummy_cmp_unique { };
//! Equivalent to std::unique algorithms.
//!
//! Removes consecutive duplicates from the stream.
//! Uses BinaryPredicate to compare elements of the stream
template <class Input, class BinaryPredicate = dummy_cmp_unique>
class unique
{
Input& input;
BinaryPredicate binary_pred;
typename Input::value_type current;
public:
//! Standard stream typedef.
typedef typename Input::value_type value_type;
unique(Input& input_, BinaryPredicate binary_pred_)
: input(input_), binary_pred(binary_pred_)
{
if (!input.empty())
current = *input;
}
//! Standard stream method.
unique& operator ++ ()
{
value_type old_value = current;
++input;
while (!input.empty() && (binary_pred(current = *input, old_value)))
++input;
return *this;
}
//! Standard stream method.
const value_type& operator * () const
{
return current;
}
//! Standard stream method.
const value_type* operator -> () const
{
return ¤t;
}
//! Standard stream method.
bool empty() const
{
return input.empty();
}
};
//! Equivalent to std::unique algorithms.
//!
//! Removes consecutive duplicates from the stream.
template <class Input>
class unique<Input, dummy_cmp_unique>
{
Input& input;
typename Input::value_type current;
public:
//! Standard stream typedef.
typedef typename Input::value_type value_type;
unique(Input& input_) : input(input_)
{
if (!input.empty())
current = *input;
}
//! Standard stream method.
unique& operator ++ ()
{
value_type old_value = current;
++input;
while (!input.empty() && ((current = *input) == old_value))
++input;
return *this;
}
//! Standard stream method.
const value_type& operator * () const
{
return current;
}
//! Standard stream method.
const value_type* operator -> () const
{
return ¤t;
}
//! Standard stream method.
bool empty() const
{
return input.empty();
}
};
//! \}
} // namespace stream
STXXL_END_NAMESPACE
#endif // !STXXL_STREAM_UNIQUE_HEADER
// vim: et:ts=4:sw=4
|