00001 /********************************************************************** 00002 * File: sortflts.h (Formerly sfloats.h) 00003 * Description: Code to maintain a sorted list of floats. 00004 * Author: Ray Smith 00005 * Created: Mon Oct 4 16:15:40 BST 1993 00006 * 00007 * (C) Copyright 1993, Hewlett-Packard Ltd. 00008 ** Licensed under the Apache License, Version 2.0 (the "License"); 00009 ** you may not use this file except in compliance with the License. 00010 ** You may obtain a copy of the License at 00011 ** http://www.apache.org/licenses/LICENSE-2.0 00012 ** Unless required by applicable law or agreed to in writing, software 00013 ** distributed under the License is distributed on an "AS IS" BASIS, 00014 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 ** See the License for the specific language governing permissions and 00016 ** limitations under the License. 00017 * 00018 **********************************************************************/ 00019 00020 #ifndef SORTFLTS_H 00021 #define SORTFLTS_H 00022 00023 #include "elst.h" 00024 #include "notdll.h" 00025 #include "notdll.h" 00026 00027 class SORTED_FLOAT:public ELIST_LINK 00028 { 00029 friend class SORTED_FLOATS; 00030 00031 public: 00032 SORTED_FLOAT() { 00033 } //empty constructor 00034 SORTED_FLOAT( //create one 00035 float value, //value of entry 00036 inT32 key) { //reference 00037 entry = value; 00038 address = key; 00039 } 00040 private: 00041 float entry; //value of float 00042 inT32 address; //key 00043 }; 00044 00045 ELISTIZEH (SORTED_FLOAT) 00046 class SORTED_FLOATS 00047 { 00048 public: 00049 SORTED_FLOATS() { //empty constructor 00050 it.set_to_list (&list); 00051 } 00052 void add( //add sample 00053 float value, //sample float 00054 inT32 key); //retrieval key 00055 void remove( //delete sample 00056 inT32 key); //key to delete 00057 float operator[] ( //index to list 00058 inT32 index); //item to get 00059 00060 private: 00061 SORTED_FLOAT_LIST list; //list of floats 00062 SORTED_FLOAT_IT it; //iterator built-in 00063 }; 00064 #endif