/*
    $Id: misc.h 1109 2007-04-17 00:04:26Z rvernica $

    Copyright (C) 2007 by The Regents of the University of California

    Redistribution of this file is permitted under the terms of the
    GNU Public License (GPL).

    Date: 01/30/2007
    Author: Rares Vernica <rvernica@ics.uci.edu>
*/

#ifndef _misc_h_
#define _misc_h_

#include <string>
#include <vector>

using namespace std;

// x^y
unsigned pow(unsigned x, unsigned y);

// all possible subsets of k elements from 0..n-1
vector<vector<unsigned> > subsets(unsigned n, unsigned k);

inline unsigned min(unsigned x, unsigned y, unsigned z) {
  return (x < y ? (x < z ? x : z) : (y < z ? y : z));
}

// unsigned to string
string utos(unsigned i);
string utosh(unsigned i);       // human representation

class UnsignedSeq 
{
private:
  unsigned value;
public:
  UnsignedSeq(unsigned initialValue = 0);
  unsigned operator() ();
};

string removeExt(const string filename);

void writeerror(const string filename);
void readerror(const string filename);

#endif
