Untitled

mail@pastecode.io avatar
unknown
c_cpp
16 days ago
1.2 kB
3
Indexable
Never
    template <typename T>
	std::string cyclic_double_queue<T>::print_status() const
	{
		//TODO: Remove following line and add your implementation here.
		std::string result;
        if(m_size == 0){
            for(size_t i = 0; i<m_capacity; ++i){
                result += "[-]";
            }
        }
        else {
            for (size_t i = 0; i < m_capacity; ++i) { // 2
                // if ( i < m_backIndex && m_backIndex < m_frontIndex) {
                //     // queue is B - F
                //     result += "[+]";
                // }
                // else if (i >= m_frontIndex && i < m_backIndex && m_backIndex < m_capacity) {
                //     // queue is F - B
                //  result += "[+]";   
                // }
                // else {
                // 	result += "[-]";
                // }
                if(i < m_backIndex && i < m_frontIndex){
                    result += "[+]";
                }
                else if(i < m_frontIndex){
                    result += "[-]";
                }
                else{
                    result += "[+]";
                }
            }
        }
        return result;
    }
Leave a Comment