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.
//
/*
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 <iterator>
#include <algorithm>
/**
T is the memory-type (normally bytes aka char)
OutputIterator is where to write (normally cout)
*/
namespace brainfuck_details {
// 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);
}
#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:
"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.
NOTE:
This headers is purely a handy tool for the "for(auto x : counter(v))"-syntax. Using it explicitly with iterators is not recommended!
NOTE:
This headers is purely a handy tool for the "for(auto x : counter(v))"-syntax. Using it explicitly with iterators is not recommended!
NOTE:
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:
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).
#ifndef COUNTING_ITERATOR_HPP
#define COUNTING_ITERATOR_HPP
*/
#include <iterator>
// A reference is a struct, yuk...
@ -102,3 +104,5 @@ counting_container<Container, Integer> counted(Container& 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.
*/
#ifndef AwesomeAttractorND_nd_array_hpp
#define AwesomeAttractorND_nd_array_hpp
#ifndef ND_ARRAY_HPP
#define ND_ARRAY_HPP
#include <stdexcept>
#include <numeric>
@ -153,4 +153,4 @@ private:
std::array<size_type, dimension> sizes;
};
#endif
#endif // ND_ARRAY_HPP