/usr/include/stxxl/bits/stream/unique.h is in libstxxl-dev 1.3.1-5ubuntu1.
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 | /***************************************************************************
* 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_H
#define STXXL_STREAM__UNIQUE_H
#include <stxxl/bits/namespace.h>
__STXXL_BEGIN_NAMESPACE
//! \brief Stream package subnamespace
namespace stream
{
////////////////////////////////////////////////////////////////////////
// UNIQUE //
////////////////////////////////////////////////////////////////////////
struct dummy_cmp_unique_ { };
//! \brief 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:
//! \brief 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;
}
//! \brief Standard stream method
unique & operator ++ ()
{
value_type old_value = current;
++input;
while (!input.empty() && (binary_pred(current = *input, old_value)))
++input;
return *this;
}
//! \brief Standard stream method
const value_type & operator * () const
{
return current;
}
//! \brief Standard stream method
const value_type * operator -> () const
{
return ¤t;
}
//! \brief Standard stream method
bool empty() const
{
return input.empty();
}
};
//! \brief 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:
//! \brief Standard stream typedef
typedef typename Input::value_type value_type;
unique(Input & input_) : input(input_)
{
if (!input.empty())
current = *input;
}
//! \brief Standard stream method
unique & operator ++ ()
{
value_type old_value = current;
++input;
while (!input.empty() && ((current = *input) == old_value))
++input;
return *this;
}
//! \brief Standard stream method
const value_type & operator * () const
{
return current;
}
//! \brief Standard stream method
const value_type * operator -> () const
{
return ¤t;
}
//! \brief Standard stream method
bool empty() const
{
return input.empty();
}
};
//! \}
}
__STXXL_END_NAMESPACE
#endif // !STXXL_STREAM__UNIQUE_H
// vim: et:ts=4:sw=4
|