Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
| Download
GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
Project: cocalc-sagemath-dev-slelievre
Path: gap4r8 / pkg / NormalizInterface-1.0.2 / Normaliz.git / Qsource / libQnormaliz / Qmap_operations.h
Views: 418384/*1* Normaliz2* Copyright (C) 2007-2014 Winfried Bruns, Bogdan Ichim, Christof Soeger3* This program is free software: you can redistribute it and/or modify4* it under the terms of the GNU General Public License as published by5* the Free Software Foundation, either version 3 of the License, or6* (at your option) any later version.7*8* This program is distributed in the hope that it will be useful,9* but WITHOUT ANY WARRANTY; without even the implied warranty of10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11* GNU General Public License for more details.12*13* You should have received a copy of the GNU General Public License14* along with this program. If not, see <http://www.gnu.org/licenses/>.15*16* As an exception, when this program is distributed through (i) the App Store17* by Apple Inc.; (ii) the Mac App Store by Apple Inc.; or (iii) Google Play18* by Google Inc., then that store may impose any digital rights management,19* device limits and/or redistribution restrictions that are required by its20* terms of service.21*/2223//---------------------------------------------------------------------------2425#ifndef MAP_OPERATIONS_H26#define MAP_OPERATIONS_H2728//---------------------------------------------------------------------------2930#include <map>31#include <ostream>3233namespace libQnormaliz {34using std::map;35using std::vector;3637template<typename key, typename T>38std::ostream& operator<< (std::ostream& out, const map<key, T> M) {39typename map<key, T>::const_iterator it;40for (it = M.begin(); it != M.end(); ++it) {41out << it->first << ": " << it-> second << " ";42}43out << std::endl;44return out;45}4647//---------------------------------------------------------------------------4849template<typename key, typename T>50bool exists_element(const map<key, T>& m, const key& k){51return (m.find(k) != m.end());52}5354//---------------------------------------------------------------------------5556template<typename key, typename T>57map<key, T> count_in_map (const vector<key> v) {58map<key, T> m;59T size = v.size();60for (T i = 0; i < size; ++i) {61m[v[i]]++;62}63return m;64}6566template<typename key, typename T>67vector<key> to_vector (const map<key, T> M) {68vector<key> v;69typename map<key, T>::const_iterator it;70for (it = M.begin(); it != M.end(); ++it) {71for (T i = 0; i < it->second; i++) {72v.push_back(it->first);73}74}75return v;76}7778} //end namespace7980//---------------------------------------------------------------------------81#endif82//---------------------------------------------------------------------------838485