1*dd7bc091SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*dd7bc091SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*dd7bc091SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*dd7bc091SAndrew Rist * distributed with this work for additional information 6*dd7bc091SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*dd7bc091SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*dd7bc091SAndrew Rist * "License"); you may not use this file except in compliance 9*dd7bc091SAndrew Rist * with the License. You may obtain a copy of the License at 10*dd7bc091SAndrew Rist * 11*dd7bc091SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*dd7bc091SAndrew Rist * 13*dd7bc091SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*dd7bc091SAndrew Rist * software distributed under the License is distributed on an 15*dd7bc091SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*dd7bc091SAndrew Rist * KIND, either express or implied. See the License for the 17*dd7bc091SAndrew Rist * specific language governing permissions and limitations 18*dd7bc091SAndrew Rist * under the License. 19*dd7bc091SAndrew Rist * 20*dd7bc091SAndrew Rist *************************************************************/ 21*dd7bc091SAndrew Rist 22*dd7bc091SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef X2C_HEAP_HXX 25cdf0e10cSrcweir #define X2C_HEAP_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "sistr.hxx" 28cdf0e10cSrcweir 29cdf0e10cSrcweir class HeapItem; 30cdf0e10cSrcweir 31cdf0e10cSrcweir class Heap 32cdf0e10cSrcweir { 33cdf0e10cSrcweir public: 34cdf0e10cSrcweir Heap( 35cdf0e10cSrcweir unsigned i_nWidth ); 36cdf0e10cSrcweir ~Heap(); 37cdf0e10cSrcweir 38cdf0e10cSrcweir void InsertValue( 39cdf0e10cSrcweir const char * i_sKey, 40cdf0e10cSrcweir const char * i_sValue ); 41cdf0e10cSrcweir HeapItem * ReleaseTop(); /// @return must be deleted by caller of method. 42cdf0e10cSrcweir 43cdf0e10cSrcweir private: 44cdf0e10cSrcweir typedef HeapItem * Column; 45cdf0e10cSrcweir 46cdf0e10cSrcweir void IncColumn(); ActiveColumn()47cdf0e10cSrcweir Column & ActiveColumn() { return dpColumnsArray[nActiveColumn]; } 48cdf0e10cSrcweir 49cdf0e10cSrcweir Column * dpColumnsArray; 50cdf0e10cSrcweir unsigned nColumnsArraySize; 51cdf0e10cSrcweir unsigned nActiveColumn; 52cdf0e10cSrcweir }; 53cdf0e10cSrcweir 54cdf0e10cSrcweir 55cdf0e10cSrcweir class HeapItem 56cdf0e10cSrcweir { 57cdf0e10cSrcweir public: 58cdf0e10cSrcweir HeapItem( 59cdf0e10cSrcweir const char * i_sKey, 60cdf0e10cSrcweir const char * i_sValue ); 61cdf0e10cSrcweir ~HeapItem( ); 62cdf0e10cSrcweir 63cdf0e10cSrcweir bool operator<( 64cdf0e10cSrcweir const HeapItem & i_rOther ) const; operator <=(const HeapItem & i_rOther) const65cdf0e10cSrcweir bool operator<=( 66cdf0e10cSrcweir const HeapItem & i_rOther ) const 67cdf0e10cSrcweir { return ! (i_rOther < *this); } 68cdf0e10cSrcweir const Simstr & Value() const; 69cdf0e10cSrcweir const Simstr & Key() const; 70cdf0e10cSrcweir HeapItem * Next() const; 71cdf0e10cSrcweir 72cdf0e10cSrcweir void SetNext( 73cdf0e10cSrcweir HeapItem * i_pNext ); 74cdf0e10cSrcweir private: 75cdf0e10cSrcweir Simstr sValue; 76cdf0e10cSrcweir Simstr sKey; 77cdf0e10cSrcweir HeapItem * pNext; 78cdf0e10cSrcweir }; 79cdf0e10cSrcweir 80cdf0e10cSrcweir 81cdf0e10cSrcweir 82cdf0e10cSrcweir 83cdf0e10cSrcweir 84cdf0e10cSrcweir 85cdf0e10cSrcweir #endif 86cdf0e10cSrcweir 87cdf0e10cSrcweir 88