Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
SVGAnimated Value
#ifndef __SVGANIMATED_H #define __SVGANIMATED_H //sammycageagle@gmail.com //Nwutobo Samuel Ugochukwu //24-August-2019 #include <vector> #include <iostream> enum ValueIndex { EBaseValue, EAnimatedValue, ECurrentValue, }; template<class T> class SVGAnimated { public: SVGAnimated(); T& operator[](ValueIndex index); const T& operator[](ValueIndex index) const; void Reset(); private: std::vector<T> m_values; }; template<class T> SVGAnimated<T>::SVGAnimated() { m_values.push_back(T()); } template<class T> void SVGAnimated<T>::Reset() { if(m_values.size() == 2) m_values.erase(m_values.begin() + 1); } template<class T> T& SVGAnimated<T>::operator[](ValueIndex index) { if(index == EAnimatedValue) { if(m_values.size() != 2) m_values.push_back(T()); return m_values[1]; } else if(index == ECurrentValue) { if(m_values.size() != 2) return m_values[0]; return m_values[1]; } return m_values[0]; //EBaseValue } template<class T> const T& SVGAnimated<T>::operator[](ValueIndex index) const { if(index == EAnimatedValue) { if(m_values.size() != 2) m_values.push_back(T()); return m_values[1]; } else if(index == ECurrentValue) { if(m_values.size() != 2) return m_values[0]; return m_values[1]; } return m_values[0]; //EBaseValue } int main() { SVGAnimated<int> i; i[EBaseValue] = 1; i[EAnimatedValue] = 2; i[EAnimatedValue] = 2; i[EAnimatedValue] = 2; i[EAnimatedValue] = 2; i[EAnimatedValue] = 2; i[EAnimatedValue] = 4; std::cout << i[EBaseValue]; std::cout << i[EAnimatedValue]; std::cout << i[ECurrentValue]; i.Reset(); std::cout << i[ECurrentValue]; } #endif //__SVGANIMATED_H
run
|
edit
|
history
|
help
0
Test Euler Graph
https://codeforces.com/contest/449/problem/D (INCLuSION EXCLUSION principle)
Rotate array
doubly
Tejas choudhari
Dejalo a la Suerte
Round prices
offsetof
samp error
basic observation leads to dp OPTIMIZATION from O(n^3) to O(n^2) !!! (sopj : AMBLE)