Browse Source

more consistency

master
Joshua Moerman 13 years ago
parent
commit
c9642f8c99
  1. 15
      brainfuck/brainfuck.hpp
  2. 22
      iterators/counting_iterator.hpp
  3. 6
      nd_array/nd_array.hpp

15
brainfuck/brainfuck.hpp

@ -5,15 +5,18 @@
// Copyright 2011 Vadovas. All rights reserved. // Copyright 2011 Vadovas. All rights reserved.
// //
/*
T is the memory-type (normally bytes aka char)
OutputIterator is where to write (normally cout)
*/
#ifndef BRAINFUCK_HPP
#define BRAINFUCK_HPP
#include <iostream> #include <iostream>
#include <iterator> #include <iterator>
#include <algorithm> #include <algorithm>
/**
T is the memory-type (normally bytes aka char)
OutputIterator is where to write (normally cout)
*/
namespace brainfuck_details { namespace brainfuck_details {
// recursive funtion (from http://www.xs4all.nl/~weegen/eelis/geordi/) but templated // recursive funtion (from http://www.xs4all.nl/~weegen/eelis/geordi/) but templated
@ -75,3 +78,5 @@ void brainfuck(std::string prg, InputIterator inp, OutputIterator it = brainfuck
brainfuck_details::b(c,inp,p,it); brainfuck_details::b(c,inp,p,it);
} }
#endif // BRAINFUCK_HPP

22
iterators/counting_iterator.hpp

@ -6,19 +6,21 @@
// //
/* /*
USAGE:
"for(auto x : counted(v)) { ... x.value ... x.index ... }"
x.value is a reference to the element in the container (so you can change it's value), x.index is what it is.
Container should havae forward iterators.
USAGE: NOTE:
"for(auto x : counted(v)) { ... x.value ... x.index ... }" This headers is purely a handy tool for the "for(auto x : counter(v))"-syntax. Using it explicitly with iterators is not recommended!
x.value is a reference to the element in the container (so you can change it's value), x.index is what it is.
Container should havae forward iterators.
NOTE: NOTE:
This headers is purely a handy tool for the "for(auto x : counter(v))"-syntax. Using it explicitly with iterators is not recommended! There is no const version of it. Doing "for(const auto x : counted(v))" doesn't make it impossible to change x (so the element in the container can be modified).
*/
NOTE: #ifndef COUNTING_ITERATOR_HPP
There is no const version of it. Doing "for(const auto x : counted(v))" doesn't make it impossible to change x (so the element in the container can be modified). #define COUNTING_ITERATOR_HPP
*/
#include <iterator> #include <iterator>
// A reference is a struct, yuk... // A reference is a struct, yuk...
@ -102,3 +104,5 @@ counting_container<Container, Integer> counted(Container& c){
return counting_container<Container, Integer>(c); return counting_container<Container, Integer>(c);
} }
#endif // COUNTING_ITERATOR_HPP

6
nd_array/nd_array.hpp

@ -16,8 +16,8 @@
It is templated in number of dimensions (and of course type). With extra effort you could make the dimension dynamic (ie not compile-time, but run-time), I leave that as an excercise to the reader. It is templated in number of dimensions (and of course type). With extra effort you could make the dimension dynamic (ie not compile-time, but run-time), I leave that as an excercise to the reader.
*/ */
#ifndef AwesomeAttractorND_nd_array_hpp #ifndef ND_ARRAY_HPP
#define AwesomeAttractorND_nd_array_hpp #define ND_ARRAY_HPP
#include <stdexcept> #include <stdexcept>
#include <numeric> #include <numeric>
@ -153,4 +153,4 @@ private:
std::array<size_type, dimension> sizes; std::array<size_type, dimension> sizes;
}; };
#endif #endif // ND_ARRAY_HPP