gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
hashSort.C
Go to the documentation of this file.
1 /* Copyright 2000-2018 Matt Flax <flatmax@flatmax.org>
2  This file is part of GTK+ IOStream class set
3 
4  GTK+ IOStream is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  GTK+ IOStream is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You have received a copy of the GNU General Public License
15  along with GTK+ IOStream
16  */
17 #include "hash.H"
18 #include <math.h>
19 #include <time.h>
20 
22  int cnt=10;
23  Array<int> array(cnt);
24  for (int i=0;i<cnt;i++)
25  array[i]=i;
26  for (int i=0;i<cnt+2;i++)
27  array[i]=i;
28  for (int i=0;i<cnt+1;i++)
29  cout<<array[i]<<'\n';
30  cout<<endl;
31 }
32 
33 void testArrays(){
34  Arrays< Array<int> > arrays(10);
35  for (int i=0;i<10;i++)
36  for (int j=0;j<i+1;j++)
37  arrays[i][j]=j;
38  //cout<<arrays<<endl;
39  //arrays.dump();
40  for (int i=0;i<10;i++)
41  for (int j=0;j<i+1;j++)
42  cout<<arrays[i][j]<<'\t';
43  cout<<endl;
44 }
45 
46 int main(int argc, char *argv[]){
47  //testDynamicArray();
48  //testArrays();
49  //return 0;
50  int cnt=10;
51  srand(time(NULL));
52  Array<int> array(cnt);
53  for (int i=0;i<cnt;i++){
54  array[i]=(int)round((float)(rand()-RAND_MAX/2)*2.0/(float)RAND_MAX*(float)cnt);
55  cout<<array[i]<<'\t';
56  }
57  cout<<endl;
58 
59  Hash<int> hashArrays;
60  hashArrays.hashSort(cnt, &array[0]);
61 // for (int i=0;i<hashArrays.len();i++)
62 // for (int j=0;j<hashArrays[i];j++)
63 // cout<<hashArrays[i][j]<<'\t';
64 // cout<<endl;
65 
66  return 0;
67 }
Definition: hash.H:22
int main(int argc, char *argv[])
Definition: hashSort.C:46
Definition: hash.H:36
void testDynamicArray()
Definition: hashSort.C:21
Definition: Array.H:24
double precision function round(x)
Definition: round.f:2
void testArrays()
Definition: hashSort.C:33
void hashSort(unsigned int size, int *data)
Definition: hash.H:44
gtkIOStream: /tmp/gtkiostream/include/mffm/possible.future.additions/hash/hashSort.C Source File
GTK+ IOStream  Beta