modules/up/src/gnug++/SymbolConjunctPtr.Bag.cc
/* [<][>][^][v][top][bottom][index][help] */
FUNCTIONS
This source file includes following functions.
- error
- seek
- owns
- remove
- nof
- clear
1 // This may look like C code, but it is really -*- C++ -*-
2 /*
3 Copyright (C) 1988 Free Software Foundation
4 written by Doug Lea (dl@rocky.oswego.edu)
5
6 This file is part of the GNU C++ Library. This library is free
7 software; you can redistribute it and/or modify it under the terms of
8 the GNU Library General Public License as published by the Free
9 Software Foundation; either version 2 of the License, or (at your
10 option) any later version. This library is distributed in the hope
11 that it will be useful, but WITHOUT ANY WARRANTY; without even the
12 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13 PURPOSE. See the GNU Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19 #ifdef __GNUG__
20 #pragma implementation
21 #endif
22 #include "config.h"
23 #include "SymbolConjunctPtr.Bag.h"
24 #include <builtin.h>
25
26 // error handling
27
28 void SymbolConjunctPtrBag::error(const char* msg)
/* [<][>][^][v][top][bottom][index][help] */
29 {
30 (*lib_error_handler)("Bag", msg);
31 }
32
33
34 Pix SymbolConjunctPtrBag::seek(SymbolConjunctPtr item, Pix i)
/* [<][>][^][v][top][bottom][index][help] */
35 {
36 if (i == 0)
37 i = first();
38 else
39 next(i);
40 for (;i != 0 && (!(SymbolConjunctPtrEQ((*this)(i), item))); next(i));
41 return i;
42 }
43
44 int SymbolConjunctPtrBag::owns(Pix p)
/* [<][>][^][v][top][bottom][index][help] */
45 {
46 if (p == 0) return 0;
47 for (Pix i = first(); i != 0; next(i)) if (i == p) return 1;
48 return 0;
49 }
50
51 void SymbolConjunctPtrBag::remove(SymbolConjunctPtr item)
/* [<][>][^][v][top][bottom][index][help] */
52 {
53 int i = nof(item);
54 while (i-- > 0) del(item);
55 }
56
57
58 int SymbolConjunctPtrBag::nof(SymbolConjunctPtr item)
/* [<][>][^][v][top][bottom][index][help] */
59 {
60 int n = 0;
61 for (Pix p = first(); p; next(p)) if (SymbolConjunctPtrEQ((*this)(p), item)) ++n;
62 return n;
63 }
64
65 void SymbolConjunctPtrBag::clear()
/* [<][>][^][v][top][bottom][index][help] */
66 {
67 Pix i = first();
68 while (i != 0)
69 {
70 del((*this)(i));
71 i = first();
72 }
73 }
74
75