Stan  2.10.0
probability, sampling & optimization
index_list.hpp
Go to the documentation of this file.
1 #ifndef STAN_MODEL_INDEXING_INDEX_LIST_HPP
2 #define STAN_MODEL_INDEXING_INDEX_LIST_HPP
3 
4 
5 namespace stan {
6  namespace model {
7 
11  struct nil_index_list {
12  };
13 
14 
22  template <typename H, typename T>
23  struct cons_index_list {
24  const H head_;
25  const T tail_;
26 
34  explicit cons_index_list(const H& head, const T& tail)
35  : head_(head),
36  tail_(tail) {
37  }
38  };
39 
40  // factory-like function does type inference for I and T
41  template <typename I, typename T>
42  inline cons_index_list<I, T>
43  cons_list(const I& idx1, const T& t) {
44  return cons_index_list<I, T>(idx1, t);
45  }
46 
47  inline nil_index_list
49  return nil_index_list();
50  }
51 
52  template <typename I>
53  inline cons_index_list<I, nil_index_list>
54  index_list(const I& idx) {
55  return cons_list(idx, index_list());
56  }
57 
58  template <typename I1, typename I2>
59  inline cons_index_list<I1, cons_index_list<I2, nil_index_list> >
60  index_list(const I1& idx1, const I2& idx2) {
61  return cons_list(idx1, index_list(idx2));
62  }
63 
64  template <typename I1, typename I2, typename I3>
65  inline
66  cons_index_list<I1,
67  cons_index_list<I2,
68  cons_index_list<I3,
69  nil_index_list> > >
70  index_list(const I1& idx1, const I2& idx2, const I3& idx3) {
71  return cons_list(idx1, index_list(idx2, idx3));
72  }
73 
74  }
75 }
76 #endif
Probability, optimization and sampling library.
cons_index_list(const H &head, const T &tail)
Construct a non-empty index list with the specified index for a head and specified index list for a t...
Definition: index_list.hpp:34
nil_index_list index_list()
Definition: index_list.hpp:48
cons_index_list< I, T > cons_list(const I &idx1, const T &t)
Definition: index_list.hpp:43
Template structure for an index list consisting of a head and tail index.
Definition: index_list.hpp:23
Structure for an empty (size zero) index list.
Definition: index_list.hpp:11

     [ Stan Home Page ] © 2011–2016, Stan Development Team.