• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2  A sample program using sample.vector.VectorAssistant
3  and the sample.preproc package.
4
5  This automatically produces the classes representing vectors of integer
6  and vectors of java.lang.String.
7
8  To compile and run this program, do as follows:
9
10    % java sample.preproc.Compiler sample/vector/Test.j
11    % javac sample/vector/Test.java
12    % java sample.vector.Test
13
14  The first line produces one source file (sample/Test.java) and
15  two class files (sample/vector/intVector.class and
16  sample/vector/StringVector.class).
17*/
18
19package sample.vector;
20
21import java.util.Vector by sample.vector.VectorAssistant(java.lang.String);
22import java.util.Vector by sample.vector.VectorAssistant(int);
23
24public class Test {
25    public static void main(String[] args) {
26	intVector iv = new intVector();
27	iv.add(3);
28	iv.add(4);
29	for (int i = 0; i < iv.size(); ++i)
30	    System.out.println(iv.at(i));
31
32	StringVector sv = new StringVector();
33	sv.add("foo");
34	sv.add("bar");
35	for (int i = 0; i < sv.size(); ++i)
36	    System.out.println(sv.at(i));
37    }
38}
39