LocARNA-2.0.0
alphabet.hh
1 #ifndef LOCARNA_ALPHABET_HH
2 #define LOCARNA_ALPHABET_HH
3 
4 #ifdef HAVE_CONFIG_H
5 #include <config.h>
6 #endif
7 
8 #include <array>
9 #include <vector>
10 #include <iosfwd>
11 
12 namespace LocARNA {
13 
20  template <class T, std::size_t N>
21  class Alphabet : public std::array<T,N> {
22  public:
23  using value_type = T;
24 
26  using size_type = typename std::array<T,N>::size_type;
27 
30 
32  explicit
33  Alphabet(const std::array<T,N> &a);
34 
36  explicit
37  Alphabet(const std::vector<T> &v);
38 
40  explicit
41  Alphabet(const std::string &s);
42 
44  operator = (const std::array<T, N> &a);
45 
53  size_type
54  idx(const value_type &x) const;
55 
61  bool
62  in(const value_type &x) const;
63 
64  private:
66  void
67  sort();
68  };
69 
78  template <class T, size_t N>
79  std::ostream &
80  operator<<(std::ostream &out, const Alphabet<T, N> &a);
81 }
82 
83 #include "alphabet.icc"
84 
85 #endif // LOCARNA_ALPHABET_HH
Specifies an alphabet of static size.
Definition: alphabet.hh:21
Alphabet()
construct empty
Alphabet(const std::string &s)
construct from string (only T=char)
Alphabet(const std::array< T, N > &a)
construct from array of alphabet elements
size_type idx(const value_type &x) const
index of alphabet element
T value_type
type of an alphabet element
Definition: alphabet.hh:23
typename std::array< T, N >::size_type size_type
inherited size_type
Definition: alphabet.hh:26
bool in(const value_type &x) const
test alphabet element membership
Alphabet(const std::vector< T > &v)
construct from vector
Definition: aligner.cc:15
std::ostream & operator<<(std::ostream &out, const AlignerRestriction &r)
Definition: aligner_restriction.hh:135