WvStreams
wvstringtableex.cc
1#include "wvstringtable.h"
2#include "wvhashtable.h"
3#include <stdio.h>
4
5int main()
6{
7 WvStringTable t(10);
8 // size: 10 elements
9 // WvStringTable is essentially a WvHashTable
10
11
12
13 WvString s("one"), s2("two"), s3("three");
14
15 t.add(&s, false);
16 t.add(&s2,false);
17 t.add(&s3,false);
18 // t.add("foo") is not allowed
19 // refer to WvHashTable for more information
20
21 printf("%s\n", t.join(",").cstr());
22 //prints out: one,two,three
23
24
25 printf("%s\n", t.join().cstr());
26 // By default, t.join() is using " \t" as a delimiter
27 // prints out: one two three
28
29
30 t.zap();
31 //erasing all contents of t
32
33
34 t.split("a : b : c : d ", ":");
35
36 printf("%s\n", t.join(",").cstr());
37 // prints out: a , b , c , d
38
39
40 t.split("x");
41 t.split("y");
42 t.split("z");
43
44 printf("%s\n", t.join(",").cstr());
45 // prints out: a , b , c , d ,x,y,z
46
47 return 0;
48}
WvString is an implementation of a simple and efficient printable-string class.
Definition wvstring.h:330