1// This may look like C code, but it is really -*- C++ -*- 2/* 3Copyright (C) 1988 Free Software Foundation 4 written by Doug Lea (dl@rocky.oswego.edu) 5 6This file is part of GNU CC. 7 8GNU CC is distributed in the hope that it will be useful, 9but WITHOUT ANY WARRANTY. No author or distributor 10accepts responsibility to anyone for the consequences of using it 11or for whether it serves any particular purpose or works at all, 12unless he says so in writing. Refer to the GNU CC General Public 13License for full details. 14 15Everyone is granted permission to copy, modify and redistribute 16GNU CC, but only under the conditions described in the 17GNU CC General Public License. A copy of this license is 18supposed to have been given to you along with GNU CC so you 19can know your rights and responsibilities. It should be in a 20file named COPYING. Among other things, the copyright notice 21and this notice must be preserved on all copies. 22*/ 23 24#ifdef __GNUG__ 25#pragma implementation 26#endif 27#include <builtin.h> 28#include "<T>.PQ.h" 29 30 31 32<T> <T>PQ::deq() 33{ 34 <T> x = front(); 35 del_front(); 36 return x; 37} 38 39Pix <T>PQ::seek(<T&> item) 40{ 41 for (Pix i = first(); i != 0 && !(<T>EQ((*this)(i), item)); next(i)); 42 return i; 43} 44 45int <T>PQ::owns(Pix idx) 46{ 47 if (idx == 0) return 0; 48 for (Pix i = first(); i; next(i)) if (i == idx) return 1; 49 return 0; 50} 51 52void <T>PQ::clear() 53{ 54 while (count != 0) del_front(); 55} 56 57int <T>PQ::contains (<T&> item) 58{ 59 return seek(item) != 0; 60} 61 62 63void <T>PQ::error(const char* msg) 64{ 65 (*lib_error_handler)("PQ", msg); 66} 67 68