1 /* 2 This file is part of GNU APL, a free implementation of the 3 ISO/IEC Standard 13751, "Programming Language APL, Extended" 4 5 Copyright (C) 2008-2019 Dr. Jürgen Sauermann 6 7 This program is free software: you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation, either version 3 of the License, or 10 (at your option) any later version. 11 12 This program is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with this program. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 21 #include <vector> 22 23 #include "UCS_string.hh" 24 25 #ifndef __UCS_STRING_VECTOR_HH_DEFINED__ 26 #define __UCS_STRING_VECTOR_HH_DEFINED__ 27 28 //----------------------------------------------------------------------------- 29 /// a vector of UCS_strings. 30 class UCS_string_vector : public std::vector<UCS_string> 31 { 32 public: 33 /// constructor: empty string vector UCS_string_vector()34 UCS_string_vector() {} 35 36 /// constructor: from APL character matrix (removes trailing blanks) 37 UCS_string_vector(const Value & val, bool surrogate); 38 39 /// return true iff one of the strings is equal to \b ucs contains(const UCS_string & ucs) const40 bool contains(const UCS_string & ucs) const 41 { 42 loop(s, size()) if (ucs == at(s)) return true; 43 return false; 44 } 45 46 /// sort strings sort()47 void sort() 48 { 49 if (size() < 2) return; 50 Heapsort<UCS_string>::sort(&front(), size(), 0, 51 UCS_string::compare_names); 52 } 53 54 /// compute columns widths so that items align nicely 55 void compute_column_width(int tab_size, std::vector<int> & result); 56 }; 57 //----------------------------------------------------------------------------- 58 59 #endif // __UCS_STRING_VECTOR_HH_DEFINED__ 60