Visit the lwnnplus home page, download the technical report in english or italian.
00001 #ifndef SHUFFLE_H 00002 #define SHUFFLE_H 00003 #include <vector> 00004 using namespace std; 00005 /* 00006 * Lightweight Neural Net ++ - shuffle class 00007 * http://lwneuralnetplus.sourceforge.net/ 00008 * 00009 * This C++ library provides the class shuffle wich implements a 00010 * vector of size n which contains numbers form 0 to n-1 in random order 00011 * 00012 * By Lorenzo Masetti <lorenzo.masetti@libero.it> and Luca Cinti <lucacinti@supereva.it> 00013 * 00014 * This library is free software; you can redistribute it and/or 00015 * modify it under the terms of the GNU Lesser General Public 00016 * License as published by the Free Software Foundation; either 00017 * version 2.1 of the License, or (at your option) any later version. 00018 * 00019 */ 00020 00025 class shuffle { 00026 public: 00030 shuffle(int n); 00031 00034 void redo(); 00035 00039 int operator[] (int x) const; 00040 00044 int size() const; 00045 00046 private: 00047 void doshuffle(); 00048 vector<int> _v; 00049 unsigned long int _count; 00050 }; 00051 00054 ostream& operator<<(ostream& os, const shuffle& s); 00055 00056 inline 00057 int shuffle::operator[] (int x) const { 00058 return _v[x]; 00059 } 00060 00061 inline 00062 int shuffle::size() const { 00063 return _v.size(); 00064 } 00065 #endif 00066 00067 00068 00069 00070 00071 00072 00073