/usr/include/hfst/implementations/ComposeIntersectUtilities.h is in libhfst45-dev 3.10.0~r2798-3.
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 | // Copyright (c) 2016 University of Helsinki
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
// See the file COPYING included with this distribution for more
// information.
#ifndef HEADER_COMPOSE_INTERSECT_UTILITIES_H
#define HEADER_COMPOSE_INTERSECT_UTILITIES_H
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <vector>
#include <algorithm>
#include <utility>
namespace hfst
{
namespace implementations
{
namespace compose_intersect_utilities
{
template <class X,class C> class SpaceSavingSet
{
protected:
typedef std::vector<X> XVector;
public:
typedef typename XVector::const_iterator const_iterator;
typedef typename XVector::iterator iterator;
const_iterator begin(void) const
{ return container_.begin(); }
const_iterator end(void) const
{ return container_.end(); }
iterator begin(void)
{ return container_.begin(); }
iterator end(void)
{ return container_.end(); }
SpaceSavingSet &operator=(const SpaceSavingSet &another)
{
container_ = another.container_;
return *this;
}
void insert(const X &x)
{
iterator least_upper_bound = get_least_upper_bound(x);
const X &new_x = *least_upper_bound;
if (least_upper_bound == end() || !(x == new_x))
{ add_value(x,least_upper_bound); }
}
const_iterator find(const X &x) const
{
const_iterator least_upper_bound = get_least_upper_bound(x);
if (least_upper_bound == end())
{ return end(); }
const X &new_x = *least_upper_bound;
if (new_x != x)
{ return end(); }
return least_upper_bound;
}
void clear(void)
{ container_.clear(); }
bool has_element(const X &x) const
{ return find(x) != end(); }
size_t size(void) const
{ return container_.size(); }
protected:
static C comparator;
static struct ReverseCompare
{
bool operator() (const X &x1,const X &x2) const
{ return comparator()(x1,x2); }
} reverse_comp;
XVector container_;
const_iterator get_least_upper_bound(const X &x) const
{
const_iterator it = container_.begin();
for ( ; it != container_.end(); ++it)
{
if (! comparator(*it,x))
{ break; }
}
return it;
}
iterator get_least_upper_bound(const X &x)
{
iterator it = container_.begin();
for ( ; it != container_.end(); ++it)
{
if (! comparator(*it,x))
{ break; }
}
return it;
}
void add_value(const X &x,iterator least_upper_bound)
{ container_.insert(least_upper_bound,x); }
};
}
}
}
#endif // HEADER_COMPOSE_INTERSECT_UTILITIES_H
|