14 #ifndef CEAMMC_ATOMLIST_H
15 #define CEAMMC_ATOMLIST_H
30 std::vector<Atom> atoms_;
31 typedef std::vector<Atom> atom_list;
32 typedef atom_list::const_iterator const_atom_iterator;
33 typedef atom_list::iterator atom_iterator;
34 typedef atom_list::reverse_iterator atom_riterator;
36 static bool calc_rel_idx(
int pos,
size_t* dest,
size_t sz);
37 bool getRelativeIdx(
int pos,
size_t* idx)
const;
55 const Atom&
at(
size_t pos)
const;
136 bool property(
const std::string& name,
Atom* dest)
const;
158 bool remove(
size_t pos);
165 void fill(
const Atom& a,
size_t sz);
213 size_t asSizeT(
size_t defaultValue = 0)
const;
247 template <
typename T>
294 template <
typename T>
298 AtomList::const_atom_iterator it;
299 for (it = atoms_.begin(); it != atoms_.end(); ++it) {
300 accum = fn(accum, *it);
312 template <
typename T>
313 static Atom atomFrom(T v) {
return Atom(v); }
315 Atom atomFrom(
const std::string& v);
317 template <
typename T>
318 static AtomList listFrom(T v)
321 res.
append(atomFrom<T>(v));
325 AtomList listFrom(
bool v);
326 AtomList listFrom(
const std::string& v);
327 AtomList listFrom(
const std::vector<std::string>& v);
328 AtomList listFrom(
const AtomList& v);
330 template <
typename T>
331 static T atomlistToValue(
const AtomList&,
const T& def) {
return def; }
334 bool atomlistToValue(
const AtomList& l,
const bool& def)
340 return l[0].asFloat(0.f) != 0.f;
343 return l[0].asSymbol() ==
gensym(
"true");
349 float atomlistToValue(
const AtomList& l,
const float& def)
354 return l[0].asFloat(def);
358 double atomlistToValue(
const AtomList& l,
const double& def)
363 return static_cast<double>(l[0].asFloat(static_cast<float>(def)));
367 int atomlistToValue(
const AtomList& l,
const int& def)
372 return static_cast<int>(l[0].asFloat(def));
376 size_t atomlistToValue(
const AtomList& l,
const size_t& def)
382 if (!l[0].getFloat(&v))
388 return static_cast<size_t>(v);
395 return const_cast<t_symbol*>(def);
397 if (!l[0].isSymbol())
398 return const_cast<t_symbol*>(def);
400 return l[0].asSymbol();
414 #endif // CEAMMC_ATOMLIST_H
void replaceAll(const Atom &old_value, const Atom &new_value)
void removeAll(const Atom &a)
AtomList & operator+=(double v)
Definition: ceammc_atom.h:23
bool operator!=(const Atom &a1, const Atom &a2)
Definition: ceammc_atomlist.h:240
size_t asSizeT(size_t defaultValue=0) const
static AtomList zeroes(size_t n)
bool noneOff(AtomPredicate pred) const
Definition: ceammc_atomlist.h:242
Definition: ceammc_atomlist.h:241
static AtomList filled(const Atom &a, size_t n)
bool property(const std::string &name, Atom *dest) const
AtomList operator-(double v) const
void output(t_outlet *x) const
AtomList & operator*=(double v)
static AtomList add(const AtomList &a, const AtomList &b, NonEqualLengthBehaivor lb=MINSIZE)
returns new list that is a sum of original list values and new list ("l") values
void resizeClip(size_t n)
void outputAtoms(t_outlet *x) const
output list atoms separatly, one by one
void append(const Atom &a)
Atom(* AtomMapFunction)(const Atom &a)
Definition: ceammc_atomlist.h:27
void outputAsAny(t_outlet *x) const
static AtomList sub(const AtomList &a, const AtomList &b, NonEqualLengthBehaivor lb=MINSIZE)
returns new list that contains difference from given lists
size_t count(const Atom &a) const
EXTERN t_symbol * gensym(const char *s)
int findPos(const Atom &a) const
Definition: ceammc_atomlist.h:244
static AtomList values(size_t n,...)
static AtomList ones(size_t n)
Definition: ceammc_atomlist.h:243
bool(* AtomPredicate)(const Atom &a)
Definition: ceammc_atomlist.h:25
void fromPdData(size_t n, t_atom *lst)
NonEqualLengthBehaivor
Definition: ceammc_atomlist.h:239
bool anyOff(AtomPredicate pred) const
friend bool operator==(const AtomList &l1, const AtomList &l2)
const Atom * find(const Atom &a) const
AtomList & operator/=(double v)
AtomList operator+(double v) const
AtomList operator/(double v) const
t_atom * toPdData() const
AtomList filtered(AtomPredicate pred) const
Atom & at(size_t pos)
returns reference to element at specified position
AtomList operator*(double v) const
bool contains(const Atom &a) const
Atom * relativeAt(int pos)
Definition: ceammc_atomlist.h:29
friend bool operator!=(const AtomList &l1, const AtomList &l2)
PD_FLOATTYPE t_float
Definition: m_pd.h:107
t_float reduceFloat(t_float init, t_float def, t_float(*fn)(t_float, t_float)) const
#define t_outlet
Definition: m_pd.h:189
void resizeFold(size_t n)
Atom(* AtomGenerator)()
Definition: ceammc_atomlist.h:26
bool to_outlet(t_outlet *x, const Atom &a)
bool range(Atom &min, Atom &max) const
void resizePad(size_t n, const Atom &v)
AtomList subList(int begin, int end)
bool operator==(const Atom &a1, const Atom &a2)
std::ostream & operator<<(std::ostream &os, const Atom &a)
Atom & operator[](size_t pos)
AtomList & operator-=(double v)
bool allOff(AtomPredicate pred) const
T reduce(T init, T(*fn)(const Atom &, const Atom &)) const
Definition: ceammc_atomlist.h:295
const Atom * findLast(const Atom &a) const
bool hasProperty(const std::string &name) const
std::deque< AtomList > properties() const
bool insert(size_t pos, const Atom &a)
FloatList asFloats() const
AtomList slice(int start) const
void resizeWrap(size_t n)
std::vector< t_float > FloatList
Definition: ceammc_atomlist.h:24