source: git/ntl/doc/pair.txt @ 6ce030f

spielwiese
Last change on this file since 6ce030f was 2cfffe, checked in by Hans Schönemann <hannes@…>, 21 years ago
This commit was generated by cvs2svn to compensate for changes in r6316, which included commits to RCS files with non-trunk default branches. git-svn-id: file:///usr/local/Singular/svn/trunk@6317 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 2.6 KB
Line 
1/**************************************************************************\
2
3MODULE: pair
4
5SUMMARY:
6
7Macros are defined providing template-like classes for pairs.
8
9The macro NTL_pair_decl(S,T,pair_S_T) declares a class pair_S_T whose
10implementation can be instatntiated with NTL_pair_impl(S,T,pair_S_T).  It is
11presumed that the underlying types have a default constructor, a copy
12constructor, and assignment operator, and a destructor (this is
13normally the case for most types).
14
15If S and T support I/O operator << and >>, then pair_S_T can be made
16to support these operators as well using NTL_pair_io_decl(S,T,pair_S_T) and
17NTL_pair_io_impl(S,T,pair_S_T).
18
19The same goes for the equaltity operators == and != using
20NTL_pair_eq_decl(S,T,pair_S_T) and NTL_pair_eq_impl(S,T,pair_S,T).
21
22The decalaration
23
24   pair_S_T p;
25
26creates a pair object using the default constructors for S and T.  The
27member p.a is the first component (of type S) and the member p.b is
28the second component (of type T).
29
30
31\**************************************************************************/
32
33
34
35#include <NTL/tools.h>
36
37class pair_S_T { 
38public: 
39   S a; 
40   T b; 
41 
42   pair_S_T();
43   // default constructor...invokes default constructors for S and T
44
45   pair_S_T(const pair_S_T& x); // copy
46
47   pair_S_T& operator=(const pair_S_T& x); // assignment
48
49   pair_S_T(const S& x, const T& y);  // initialize with (x, y)
50
51   ~pair_S_T();
52   // destructor...invokes destructors for S and T
53}; 
54 
55pair_S_T cons(const S& x, const T& y);
56// returns pair_S_T(x, y)
57
58
59/**************************************************************************\
60
61                             Input/Output
62
63The I/O operators can be declared with NTL_pair_io_decl(S,T,pair_S_T), and
64implemented using NTL_pair_io_impl(S,T,pair_S_T). 
65Elements are read and written using the underlying I/O
66operators << and >> for S and T.
67
68The I/O format for a pair_a_b is
69
70   [a b]
71
72\**************************************************************************/
73
74
75
76istream& operator>>(istream&, pair_S_T&); 
77ostream& operator<<(ostream&, const pair_S_T&); 
78
79
80/**************************************************************************\
81
82                              Equality Testing
83
84The equality testing operators == and != can be declared with
85NTL_pair_eq_decl(S,T,pair_S_T) and implemented with
86NTL_pair_eq_impl(S,T,pair_S,T).  The tests are performed using
87the underlying operator == for S and T.
88
89\**************************************************************************/
90
91
92long operator==(const pair_S_T& x, const pair_S_T& y);
93long operator!=(const pair_S_T& x, const pair_S_T& y);
94
95
Note: See TracBrowser for help on using the repository browser.