#ifndef PERM_H
#define PERM_H

#include <String.h>
#include <iostream.h>

//============================================================
// PERM - The class PERM represents a Permutation
//============================================================

class PERM
{
public:
    int table[32];

    PERM(int t[32])
        {
            for( int i=0; i<27; i++)
                table[i] = t[i];
        }
    
         
    PERM()
        {
            for( int i=0; i<27; i++)
                table[i] = i;
        }
    
    void Swap(int i, int j)
        {
            int t;
            t = table[i];
            table[i] = table[j];
            table[j] =t;
        }

    int Translate(int c)
        {
            return table[c];
        }

    void Randomize()
    {
        for( int i=0; i<27; i++ )
        {
            Swap(i,rand() % 27);
         }
    }


    void LocalRandomize()
    {
        for( int i=0; i<27; i++ )
        {
            int pos = rand() % 26;
            Swap(pos, pos+1);
         }
    }

    void Print(ostream& o)
        {
            for( int i=0; i<27; i++ )
                o << table[i] << ",";
            o << endl;
        }
};

#endif

