GTK+ IOStream
Beta
<< GTK+ >> add C++ IOStream operators to GTK+. Now with extra abilities ... like network serialisation
Main Page
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
mffm
possible.future.additions
hash
hashSort.C
Go to the documentation of this file.
1
/* Copyright 2000-2012 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
21
void
testDynamicArray
(){
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
}
Generated on Tue Jun 4 2013 11:03:27 for GTK+ IOStream by
1.8.3.1