Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1.  
  2. //<--- delta - function --->
  3. enum class delta_function_type { encode, decode };
  4.  
  5. template<delta_function_type T>
  6. class delta_function {
  7. public:
  8. int operator()(int in);
  9. private:
  10. int last = 0;
  11. };
  12.  
  13. template <>
  14. int inline delta_function<delta_function_type::encode>::operator()(int in) {
  15. int current = in;
  16. int res = current - last;
  17. last = current;
  18. return res;
  19. }
  20.  
  21. template <>
  22. int inline delta_function<delta_function_type::decode>::operator()(int in) {
  23. int res = in + last;
  24. last = res;
  25. return res;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement