Empirical
LinearCode.h
Go to the documentation of this file.
1 
10 #ifndef EMP_LINEAR_CODE_H
11 #define EMP_LINEAR_CODE_H
12 
13 #include "../base/array.h"
14 #include "../base/vector.h"
15 
16 namespace emp {
17 
19  template <size_t ARG_COUNT, typename ARG_TYPE=size_t>
20  struct Instruction {
22 
23  size_t id;
25 
26  Instruction(size_t _id=0, const args_t & in_args={}) : id(_id), args(in_args) { ; }
27  Instruction(const Instruction &) = default;
28  Instruction(Instruction &&) = default;
29 
31  Instruction & operator=(const Instruction &) = default;
32 
34  Instruction & operator=(Instruction &&) = default;
35 
37  bool operator<(const Instruction & other) const {
38  if (id == other.id) return args < other.args;
39  return id < other.id;
40  }
41 
43  void Set(size_t _id, const args_t & in_args) { id = _id; args = in_args; }
44 
46  bool operator==(const Instruction & in) const { return id == in.id && args == in.args; }
47  };
48 
49 
50  // template <size_t ARG_COUNT=3, typename ARG_TYPE=size_t>
51  // using LinearCode = emp::vector<Instruction<ARG_COUNT, ARG_TYPE>>;
52 
53  template <size_t ARG_COUNT=3, typename ARG_TYPE=size_t>
54  class LinearCode : public emp::vector<Instruction<ARG_COUNT, ARG_TYPE>> {
55  public:
56  void AddInst(size_t id, const emp::array<ARG_TYPE, ARG_COUNT> & in_args={}) {
58  }
59  };
60 
61 }
62 
63 
64 #endif
bool operator<(const Instruction &other) const
Test if this instruction is less than another.
Definition: LinearCode.h:37
Definition: LinearCode.h:54
Instruction(size_t _id=0, const args_t &in_args={})
Definition: LinearCode.h:26
Instruction & operator=(const Instruction &)=default
Copy operator.
void Set(size_t _id, const args_t &in_args)
Explicitly set the instruction type and specific arguments for this instruction.
Definition: LinearCode.h:43
args_t args
A set of arguments defining the specific behavior of this instruction.
Definition: LinearCode.h:24
void AddInst(size_t id, const emp::array< ARG_TYPE, ARG_COUNT > &in_args={})
Definition: LinearCode.h:56
size_t id
Unique value identifying which instruction this is.
Definition: LinearCode.h:23
bool operator==(const Instruction &in) const
Test if this instruction is identical to another.
Definition: LinearCode.h:46
If we are in emscripten, make sure to include the header.
Definition: array.h:37
A single instruction in a linear genome.
Definition: LinearCode.h:20
Build a debug wrapper emp::vector around std::vector.
Definition: vector.h:42