/**********************************************************************
 * lfl: Linguistic Fuzzy Logic
 * Copyright (C) 2025 Michal Burda
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
 **********************************************************************/


/*
 * File name: common.h
 * Date:      2013/09/09 13:16
 * Author:    Michal Burda
 */


#ifndef __LFL__COMMON_H__
#define __LFL__COMMON_H__


// comment to switch off assertions:
//#undef NDEBUG

#include <assert.h>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>


#define printVector(x) { \
    for (auto v : x) { \
        std::cout << " " << v; \
    } \
}


enum { nullId = -1 };


typedef unsigned int IdType;

typedef std::vector<IdType> IdVector;
typedef std::set<IdType> IdSet;
typedef std::vector<double> DblVector;
typedef std::vector<std::vector<double> > Matrix;


inline std::ostream& operator<< (std::ostream& stream, const IdVector& obj) {
    bool first = true;
    for (IdVector::const_iterator it = obj.begin(); it != obj.end(); it++) {
        if (first) {
            first = false;
        }
        else {
            stream << " & ";
        }
        stream << *it;
    }
    return stream;
}


inline std::ostream& operator<< (std::ostream& stream, const IdSet& obj) {
    bool first = true;
    for (IdSet::const_iterator it = obj.begin(); it != obj.end(); it++) {
        if (first) {
            first = false;
        }
        else {
            stream << " & ";
        }
        stream << *it;
    }
    return stream;
}


#endif
