Skip to content
Snippets Groups Projects
Commit 715951a7 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

document functional and hexavigesimal headers

parent 912701ad
No related branches found
No related tags found
No related merge requests found
/* /*
* functional.hpp * functional.hpp
* *
* This file is part of Algorithms library toolkit.
* Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
* Algorithms library toolkit is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* Algorithms library toolkit is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with Algorithms library toolkit. If not, see <http://www.gnu.org/licenses/>.
*
* Created on: Apr 1, 2013 * Created on: Apr 1, 2013
* Author: Jan Travnicek * Author: Jan Travnicek
*/ */
...@@ -12,28 +28,57 @@ ...@@ -12,28 +28,57 @@
   
namespace ext { namespace ext {
   
/**
* Class extending the reference wrapper class from the standard library. Original reason is to allow its use with standard stream aggregation class.
*
* The class mimics the behavior of the reference wrapper from the standatd library.
*
* \tparam T the type of the reference inside the reference wrapper
*/
template < class T > template < class T >
class reference_wrapper : public std::reference_wrapper < T > { class reference_wrapper : public std::reference_wrapper < T > {
public: public:
#ifdef __clang__ /**
* Inherit constructors of the standard reference_wrapper.
*/
using std::reference_wrapper < T >::reference_wrapper; using std::reference_wrapper < T >::reference_wrapper;
/**
* Inherit operator = of the standard reference_wrapper.
*/
using std::reference_wrapper < T >::operator =; using std::reference_wrapper < T >::operator =;
#else
reference_wrapper ( ) noexcept : std::reference_wrapper < T > ( ) {
}
   
#ifndef __clang__
/**
* Default constructor needed by g++ since it is not inherited.
*/
reference_wrapper ( ) = default;
/**
* Copy constructor needed by g++ since it is not inherited.
*/
reference_wrapper ( const reference_wrapper & other ) = default; reference_wrapper ( const reference_wrapper & other ) = default;
   
/**
* Move constructor needed by g++ since it is not inherited.
*/
reference_wrapper ( reference_wrapper && other ) = default; reference_wrapper ( reference_wrapper && other ) = default;
   
using std::reference_wrapper < T >::reference_wrapper; /**
* Copy operator = needed by g++ since it is not inherited.
*/
reference_wrapper & operator = ( reference_wrapper && other ) = default; reference_wrapper & operator = ( reference_wrapper && other ) = default;
   
/**
* Move operator = needed by g++ since it is not inherited.
*/
reference_wrapper & operator = ( const reference_wrapper & other ) = default; reference_wrapper & operator = ( const reference_wrapper & other ) = default;
using std::reference_wrapper < T >::operator =;
#endif #endif
/**
* Inherit the accessor of the internal reference.
*/
using std::reference_wrapper < T >::operator T &; using std::reference_wrapper < T >::operator T &;
}; };
   
......
/* /*
* hexavigesimal.h * hexavigesimal.h
* *
* This file is part of Algorithms library toolkit.
* Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
* Algorithms library toolkit is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* Algorithms library toolkit is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with Algorithms library toolkit. If not, see <http://www.gnu.org/licenses/>.
*
* Created on: 19. 4. 2014 * Created on: 19. 4. 2014
* Author: Tomas Pecka * Author: Tomas Pecka
*/ */
...@@ -13,26 +29,62 @@ ...@@ -13,26 +29,62 @@
namespace ext { namespace ext {
   
/** /**
* \brief
* Function to convert a number to sequence of uppercase letters.
*
* The following translation is implemented:
*
* Maps 0 -> A, 1 -> B, ..., 25 -> Z, 26 -> AB, 27 -> AC, ..., 675 -> ZZ, 676 -> BAA, ... * Maps 0 -> A, 1 -> B, ..., 25 -> Z, 26 -> AB, 27 -> AC, ..., 675 -> ZZ, 676 -> BAA, ...
* http://en.wikipedia.org/wiki/Hexavigesimal * http://en.wikipedia.org/wiki/Hexavigesimal
*
* \param n the number to convert
*
* \return string sequence corresponding to the value in \p n
*/ */
std::string toBase26( unsigned n ); std::string toBase26( unsigned n );
   
/** /**
* \brief
* Function to convert sequence of uppercase letters to a number.
*
* The following translation is implemented:
*
* Maps A -> 0, B -> 0, ..., Z -> 25, AB -> 26, AC -> 27, ..., ZZ -> 675, BAA -> 676, ... * Maps A -> 0, B -> 0, ..., Z -> 25, AB -> 26, AC -> 27, ..., ZZ -> 675, BAA -> 676, ...
* http://en.wikipedia.org/wiki/Hexavigesimal * http://en.wikipedia.org/wiki/Hexavigesimal
*
* \param rep string sequence of uppercase letters
*
* \return the number corresponding to the value in \p rep
*/ */
unsigned fromBase26( std::string rep ); unsigned fromBase26( std::string rep );
   
/** /**
* Maps 1 -> A, 2 -> B, ..., 26 -> Z, 27 -> AA, 28 -> AB, ..., 675 -> ZZ, 676 -> BAA, ... * \brief
* Function to convert a number to sequence of uppercase letters.
*
* The following translation is implemented:
*
* Maps 1 -> A, 2 -> B, ..., 26 -> Z, 27 -> AA, 28 -> AB, ..., 676 -> ZZ, 677 -> AAA, ...
* http://en.wikipedia.org/wiki/Hexavigesimal * http://en.wikipedia.org/wiki/Hexavigesimal
*
* \param n the number to convert
*
* \return string sequence corresponding to the value in \p n
*/ */
std::string bijectiveToBase26( unsigned n ); std::string bijectiveToBase26( unsigned n );
   
/** /**
* Maps 1 -> A, 2 -> B, ..., 26 -> Z, 27 -> AA, AB -> 28, ..., ZZ -> 675, BAA -> 676, ... * \brief
* Function to convert sequence of uppercase letters to a number.
*
* The following translation is implemented:
*
* Maps 1 -> A, 2 -> B, ..., 26 -> Z, 27 -> AA, AB -> 28, ..., ZZ -> 676, AAA -> 677, ...
* http://en.wikipedia.org/wiki/Hexavigesimal * http://en.wikipedia.org/wiki/Hexavigesimal
*
* \param rep string sequence of uppercase letters
*
* \return the number corresponding to the value in \p rep
*/ */
unsigned bijectiveFromBase26( std::string rep ); unsigned bijectiveFromBase26( std::string rep );
   
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment