\hypertarget{GSeq_8cc}{
\section{GSeq.cc File Reference}
\label{GSeq_8cc}\index{GSeq.cc@{GSeq.cc}}
}
{\ttfamily \#include $<$iostream$>$}\par
{\ttfamily \#include $<$fstream$>$}\par
{\ttfamily \#include $<$cstring$>$}\par
{\ttfamily \#include $<$stdlib.h$>$}\par
\subsection*{Classes}
\begin{DoxyCompactItemize}
\item 
struct \hyperlink{structelem}{elem}
\begin{DoxyCompactList}\small\item\em Struttura del singolo elemento. \end{DoxyCompactList}\item 
struct \hyperlink{structdesc__sequenza}{desc\_\-sequenza}
\begin{DoxyCompactList}\small\item\em Descrittore di una sequenza. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
typedef \hyperlink{structelem}{elem} $\ast$ \hyperlink{GSeq_8cc_afae32ed0493ea4325e2f94541b7b7e8e}{elem\_\-p}
\end{DoxyCompactItemize}
\subsection*{Enumerations}
\begin{DoxyCompactItemize}
\item 
enum \hyperlink{GSeq_8cc_ae26ed0e7fda6833d08d70e889a0d3ef8}{tipo\_\-chiave\_\-t} \{ \hyperlink{GSeq_8cc_ae26ed0e7fda6833d08d70e889a0d3ef8a31ec0ebdab5c59e661388467a7bacea8}{CHIAVE\_\-NUMERICA}, 
\hyperlink{GSeq_8cc_ae26ed0e7fda6833d08d70e889a0d3ef8a96d5309d06f2464bf1337f3b6d325eef}{CHIAVE\_\-STRINGA}, 
\hyperlink{GSeq__1file__complete_8cc_ae26ed0e7fda6833d08d70e889a0d3ef8a31ec0ebdab5c59e661388467a7bacea8}{CHIAVE\_\-NUMERICA}, 
\hyperlink{GSeq__1file__complete_8cc_ae26ed0e7fda6833d08d70e889a0d3ef8a96d5309d06f2464bf1337f3b6d325eef}{CHIAVE\_\-STRINGA}
 \}
\item 
enum \hyperlink{GSeq_8cc_aded7eef211a32e3755ae48de409c1c54}{ins\_\-modo} \{ \par
\hyperlink{GSeq_8cc_aded7eef211a32e3755ae48de409c1c54a2442ca85f025556e6afe5bb38dcc5cff}{in\_\-testa}, 
\hyperlink{GSeq_8cc_aded7eef211a32e3755ae48de409c1c54a5ac8b47dd381ed0c2808561e0a4aec98}{in\_\-coda}, 
\hyperlink{GSeq_8cc_aded7eef211a32e3755ae48de409c1c54a137fa83c8bc11b2681ba6256272af60b}{in\_\-ordine}, 
\hyperlink{GSeq__1file__complete_8cc_aded7eef211a32e3755ae48de409c1c54a2442ca85f025556e6afe5bb38dcc5cff}{in\_\-testa}, 
\par
\hyperlink{GSeq__1file__complete_8cc_aded7eef211a32e3755ae48de409c1c54a5ac8b47dd381ed0c2808561e0a4aec98}{in\_\-coda}, 
\hyperlink{GSeq__1file__complete_8cc_aded7eef211a32e3755ae48de409c1c54a137fa83c8bc11b2681ba6256272af60b}{in\_\-ordine}
 \}
\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
void \hyperlink{GSeq_8cc_a98c57942b3eab58c3171251f86b46a97}{inizializza} (\hyperlink{structdesc__sequenza}{desc\_\-sequenza} \&s, const \hyperlink{GSeq_8cc_ae26ed0e7fda6833d08d70e889a0d3ef8}{tipo\_\-chiave\_\-t} t)
\item 
void \hyperlink{GSeq_8cc_a699ad1ebc4259268a6f34928bcba36ba}{dealloca\_\-elem} (\hyperlink{structelem}{elem} $\ast$p)
\item 
void \hyperlink{GSeq_8cc_a5e79aa45e1756e1da685e0deb903d733}{distruggi} (\hyperlink{structdesc__sequenza}{desc\_\-sequenza} \&s)
\item 
int \hyperlink{GSeq_8cc_a0f140482444126474ef9f07e7f5b28cd}{diff} (const \hyperlink{structdesc__sequenza}{desc\_\-sequenza} \&s, const char c1\mbox{[}$\,$\mbox{]}, const char c2\mbox{[}$\,$\mbox{]})
\item 
void \hyperlink{GSeq_8cc_aaf29bed7640205c32dbca4c882027e43}{inserisci} (\hyperlink{structdesc__sequenza}{desc\_\-sequenza} \&s, \hyperlink{structelem}{elem} $\ast$el, \hyperlink{GSeq_8cc_aded7eef211a32e3755ae48de409c1c54}{ins\_\-modo} modo)
\item 
int \hyperlink{GSeq_8cc_a7005c15f4f3a9f6040ae5f597d8c1aa8}{ric\_\-sequenziale} (const \hyperlink{structdesc__sequenza}{desc\_\-sequenza} \&s, const char c\mbox{[}$\,$\mbox{]})
\item 
int \hyperlink{GSeq_8cc_aa02f6182042c5e23a16f07f93377f0d5}{ric\_\-binaria} (const \hyperlink{structdesc__sequenza}{desc\_\-sequenza} \&s, const char c\mbox{[}$\,$\mbox{]})
\item 
int \hyperlink{GSeq_8cc_afe9af51fb07d753024bcf797606aed9e}{cerca} (const \hyperlink{structdesc__sequenza}{desc\_\-sequenza} \&s, const char c\mbox{[}$\,$\mbox{]})
\item 
bool \hyperlink{GSeq_8cc_a1ab927ac401a42a515b61c4e29392107}{elimina} (\hyperlink{structdesc__sequenza}{desc\_\-sequenza} \&s, const char c\mbox{[}$\,$\mbox{]})
\item 
void \hyperlink{GSeq_8cc_a2dad0010e500c42f05ae58bff0ca0b76}{stampa\_\-elem} (const \hyperlink{structelem}{elem} \&el, ostream \&os)
\item 
void \hyperlink{GSeq_8cc_aff0ea94992a6e54aec947cd7ffe0efc2}{stampa} (const \hyperlink{structdesc__sequenza}{desc\_\-sequenza} \&s)
\item 
void \hyperlink{GSeq_8cc_a32b85d9151974c75590269537470fc55}{salva} (const \hyperlink{structdesc__sequenza}{desc\_\-sequenza} \&s, const char nome\mbox{[}$\,$\mbox{]})
\item 
int \hyperlink{GSeq_8cc_ae66f6b31b5ad750f1fe042a706a4e3d4}{main} ()
\end{DoxyCompactItemize}
\subsection*{Variables}
\begin{DoxyCompactItemize}
\item 
const int \hyperlink{GSeq_8cc_ae68bf5715a32605dee2ba5beeb81fd66}{MAXLUN} = 100
\item 
const int \hyperlink{GSeq_8cc_aca05eea8d265284324bd4e8418a81508}{DIM\_\-BASE} = 100
\end{DoxyCompactItemize}


\subsection{Typedef Documentation}
\hypertarget{GSeq_8cc_afae32ed0493ea4325e2f94541b7b7e8e}{
\index{GSeq.cc@{GSeq.cc}!elem\_\-p@{elem\_\-p}}
\index{elem\_\-p@{elem\_\-p}!GSeq.cc@{GSeq.cc}}
\subsubsection[{elem\_\-p}]{\setlength{\rightskip}{0pt plus 5cm}typedef {\bf elem}$\ast$ {\bf elem\_\-p}}}
\label{GSeq_8cc_afae32ed0493ea4325e2f94541b7b7e8e}


\subsection{Enumeration Type Documentation}
\hypertarget{GSeq_8cc_aded7eef211a32e3755ae48de409c1c54}{
\index{GSeq.cc@{GSeq.cc}!ins\_\-modo@{ins\_\-modo}}
\index{ins\_\-modo@{ins\_\-modo}!GSeq.cc@{GSeq.cc}}
\subsubsection[{ins\_\-modo}]{\setlength{\rightskip}{0pt plus 5cm}enum {\bf ins\_\-modo}}}
\label{GSeq_8cc_aded7eef211a32e3755ae48de409c1c54}
\begin{Desc}
\item[Enumerator: ]\par
\begin{description}
\index{in\_\-testa@{in\_\-testa}!GSeq.cc@{GSeq.cc}}\index{GSeq.cc@{GSeq.cc}!in\_\-testa@{in\_\-testa}}\item[{\em 
\hypertarget{GSeq_8cc_aded7eef211a32e3755ae48de409c1c54a2442ca85f025556e6afe5bb38dcc5cff}{
in\_\-testa}
\label{GSeq_8cc_aded7eef211a32e3755ae48de409c1c54a2442ca85f025556e6afe5bb38dcc5cff}
}]\index{in\_\-coda@{in\_\-coda}!GSeq.cc@{GSeq.cc}}\index{GSeq.cc@{GSeq.cc}!in\_\-coda@{in\_\-coda}}\item[{\em 
\hypertarget{GSeq_8cc_aded7eef211a32e3755ae48de409c1c54a5ac8b47dd381ed0c2808561e0a4aec98}{
in\_\-coda}
\label{GSeq_8cc_aded7eef211a32e3755ae48de409c1c54a5ac8b47dd381ed0c2808561e0a4aec98}
}]\index{in\_\-ordine@{in\_\-ordine}!GSeq.cc@{GSeq.cc}}\index{GSeq.cc@{GSeq.cc}!in\_\-ordine@{in\_\-ordine}}\item[{\em 
\hypertarget{GSeq_8cc_aded7eef211a32e3755ae48de409c1c54a137fa83c8bc11b2681ba6256272af60b}{
in\_\-ordine}
\label{GSeq_8cc_aded7eef211a32e3755ae48de409c1c54a137fa83c8bc11b2681ba6256272af60b}
}]\index{in\_\-testa@{in\_\-testa}!GSeq.cc@{GSeq.cc}}\index{GSeq.cc@{GSeq.cc}!in\_\-testa@{in\_\-testa}}\item[{\em 
\hypertarget{GSeq_8cc_aded7eef211a32e3755ae48de409c1c54a2442ca85f025556e6afe5bb38dcc5cff}{
in\_\-testa}
\label{GSeq_8cc_aded7eef211a32e3755ae48de409c1c54a2442ca85f025556e6afe5bb38dcc5cff}
}]\index{in\_\-coda@{in\_\-coda}!GSeq.cc@{GSeq.cc}}\index{GSeq.cc@{GSeq.cc}!in\_\-coda@{in\_\-coda}}\item[{\em 
\hypertarget{GSeq_8cc_aded7eef211a32e3755ae48de409c1c54a5ac8b47dd381ed0c2808561e0a4aec98}{
in\_\-coda}
\label{GSeq_8cc_aded7eef211a32e3755ae48de409c1c54a5ac8b47dd381ed0c2808561e0a4aec98}
}]\index{in\_\-ordine@{in\_\-ordine}!GSeq.cc@{GSeq.cc}}\index{GSeq.cc@{GSeq.cc}!in\_\-ordine@{in\_\-ordine}}\item[{\em 
\hypertarget{GSeq_8cc_aded7eef211a32e3755ae48de409c1c54a137fa83c8bc11b2681ba6256272af60b}{
in\_\-ordine}
\label{GSeq_8cc_aded7eef211a32e3755ae48de409c1c54a137fa83c8bc11b2681ba6256272af60b}
}]\end{description}
\end{Desc}


\begin{DoxyCode}
{in_testa, in_coda, in_ordine} ;
\end{DoxyCode}
\hypertarget{GSeq_8cc_ae26ed0e7fda6833d08d70e889a0d3ef8}{
\index{GSeq.cc@{GSeq.cc}!tipo\_\-chiave\_\-t@{tipo\_\-chiave\_\-t}}
\index{tipo\_\-chiave\_\-t@{tipo\_\-chiave\_\-t}!GSeq.cc@{GSeq.cc}}
\subsubsection[{tipo\_\-chiave\_\-t}]{\setlength{\rightskip}{0pt plus 5cm}enum {\bf tipo\_\-chiave\_\-t}}}
\label{GSeq_8cc_ae26ed0e7fda6833d08d70e889a0d3ef8}
\begin{Desc}
\item[Enumerator: ]\par
\begin{description}
\index{CHIAVE\_\-NUMERICA@{CHIAVE\_\-NUMERICA}!GSeq.cc@{GSeq.cc}}\index{GSeq.cc@{GSeq.cc}!CHIAVE\_\-NUMERICA@{CHIAVE\_\-NUMERICA}}\item[{\em 
\hypertarget{GSeq_8cc_ae26ed0e7fda6833d08d70e889a0d3ef8a31ec0ebdab5c59e661388467a7bacea8}{
CHIAVE\_\-NUMERICA}
\label{GSeq_8cc_ae26ed0e7fda6833d08d70e889a0d3ef8a31ec0ebdab5c59e661388467a7bacea8}
}]\index{CHIAVE\_\-STRINGA@{CHIAVE\_\-STRINGA}!GSeq.cc@{GSeq.cc}}\index{GSeq.cc@{GSeq.cc}!CHIAVE\_\-STRINGA@{CHIAVE\_\-STRINGA}}\item[{\em 
\hypertarget{GSeq_8cc_ae26ed0e7fda6833d08d70e889a0d3ef8a96d5309d06f2464bf1337f3b6d325eef}{
CHIAVE\_\-STRINGA}
\label{GSeq_8cc_ae26ed0e7fda6833d08d70e889a0d3ef8a96d5309d06f2464bf1337f3b6d325eef}
}]\index{CHIAVE\_\-NUMERICA@{CHIAVE\_\-NUMERICA}!GSeq.cc@{GSeq.cc}}\index{GSeq.cc@{GSeq.cc}!CHIAVE\_\-NUMERICA@{CHIAVE\_\-NUMERICA}}\item[{\em 
\hypertarget{GSeq_8cc_ae26ed0e7fda6833d08d70e889a0d3ef8a31ec0ebdab5c59e661388467a7bacea8}{
CHIAVE\_\-NUMERICA}
\label{GSeq_8cc_ae26ed0e7fda6833d08d70e889a0d3ef8a31ec0ebdab5c59e661388467a7bacea8}
}]\index{CHIAVE\_\-STRINGA@{CHIAVE\_\-STRINGA}!GSeq.cc@{GSeq.cc}}\index{GSeq.cc@{GSeq.cc}!CHIAVE\_\-STRINGA@{CHIAVE\_\-STRINGA}}\item[{\em 
\hypertarget{GSeq_8cc_ae26ed0e7fda6833d08d70e889a0d3ef8a96d5309d06f2464bf1337f3b6d325eef}{
CHIAVE\_\-STRINGA}
\label{GSeq_8cc_ae26ed0e7fda6833d08d70e889a0d3ef8a96d5309d06f2464bf1337f3b6d325eef}
}]\end{description}
\end{Desc}


\begin{DoxyCode}
{CHIAVE_NUMERICA, CHIAVE_STRINGA} ;
\end{DoxyCode}


\subsection{Function Documentation}
\hypertarget{GSeq_8cc_afe9af51fb07d753024bcf797606aed9e}{
\index{GSeq.cc@{GSeq.cc}!cerca@{cerca}}
\index{cerca@{cerca}!GSeq.cc@{GSeq.cc}}
\subsubsection[{cerca}]{\setlength{\rightskip}{0pt plus 5cm}int cerca (
\begin{DoxyParamCaption}
\item[{const {\bf desc\_\-sequenza} \&}]{s, }
\item[{const char}]{c\mbox{[}$\,$\mbox{]}}
\end{DoxyParamCaption}
)}}
\label{GSeq_8cc_afe9af51fb07d753024bcf797606aed9e}

\begin{DoxyCode}
{
    return s.ordinata ? ric_binaria(s, c) : ric_sequenziale(s, c) ;
}
\end{DoxyCode}
\hypertarget{GSeq_8cc_a699ad1ebc4259268a6f34928bcba36ba}{
\index{GSeq.cc@{GSeq.cc}!dealloca\_\-elem@{dealloca\_\-elem}}
\index{dealloca\_\-elem@{dealloca\_\-elem}!GSeq.cc@{GSeq.cc}}
\subsubsection[{dealloca\_\-elem}]{\setlength{\rightskip}{0pt plus 5cm}void dealloca\_\-elem (
\begin{DoxyParamCaption}
\item[{{\bf elem} $\ast$}]{p}
\end{DoxyParamCaption}
)}}
\label{GSeq_8cc_a699ad1ebc4259268a6f34928bcba36ba}

\begin{DoxyCode}
{
    if (p->parole != 0)
        delete [] p->parole ;
    delete p ;
}
\end{DoxyCode}
\hypertarget{GSeq_8cc_a0f140482444126474ef9f07e7f5b28cd}{
\index{GSeq.cc@{GSeq.cc}!diff@{diff}}
\index{diff@{diff}!GSeq.cc@{GSeq.cc}}
\subsubsection[{diff}]{\setlength{\rightskip}{0pt plus 5cm}int diff (
\begin{DoxyParamCaption}
\item[{const {\bf desc\_\-sequenza} \&}]{s, }
\item[{const char}]{c1\mbox{[}$\,$\mbox{]}, }
\item[{const char}]{c2\mbox{[}$\,$\mbox{]}}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}inline\mbox{]}}}}
\label{GSeq_8cc_a0f140482444126474ef9f07e7f5b28cd}

\begin{DoxyCode}
{
    return s.tipo_chiave == CHIAVE_NUMERICA ? 
        atoi(c1) - atoi(c2) : strcmp(c1, c2) ;
}
\end{DoxyCode}
\hypertarget{GSeq_8cc_a5e79aa45e1756e1da685e0deb903d733}{
\index{GSeq.cc@{GSeq.cc}!distruggi@{distruggi}}
\index{distruggi@{distruggi}!GSeq.cc@{GSeq.cc}}
\subsubsection[{distruggi}]{\setlength{\rightskip}{0pt plus 5cm}void distruggi (
\begin{DoxyParamCaption}
\item[{{\bf desc\_\-sequenza} \&}]{s}
\end{DoxyParamCaption}
)}}
\label{GSeq_8cc_a5e79aa45e1756e1da685e0deb903d733}

\begin{DoxyCode}
{
    for (int i = 0 ; i < s.num_elem ; i++)
        dealloca_elem(s.elementi[i]) ;

    delete [] s.elementi ;
}
\end{DoxyCode}
\hypertarget{GSeq_8cc_a1ab927ac401a42a515b61c4e29392107}{
\index{GSeq.cc@{GSeq.cc}!elimina@{elimina}}
\index{elimina@{elimina}!GSeq.cc@{GSeq.cc}}
\subsubsection[{elimina}]{\setlength{\rightskip}{0pt plus 5cm}bool elimina (
\begin{DoxyParamCaption}
\item[{{\bf desc\_\-sequenza} \&}]{s, }
\item[{const char}]{c\mbox{[}$\,$\mbox{]}}
\end{DoxyParamCaption}
)}}
\label{GSeq_8cc_a1ab927ac401a42a515b61c4e29392107}

\begin{DoxyCode}
{
    int pos = cerca(s, c) ;
    if (pos == -1)
        return false ;
    dealloca_elem(s.elementi[pos]) ;

    for (int i = pos ; i < s.num_elem - 1 ; i++)
        s.elementi[i] = s.elementi[i+1] ;

    s.num_elem-- ;
    return true ;
}
\end{DoxyCode}
\hypertarget{GSeq_8cc_a98c57942b3eab58c3171251f86b46a97}{
\index{GSeq.cc@{GSeq.cc}!inizializza@{inizializza}}
\index{inizializza@{inizializza}!GSeq.cc@{GSeq.cc}}
\subsubsection[{inizializza}]{\setlength{\rightskip}{0pt plus 5cm}void inizializza (
\begin{DoxyParamCaption}
\item[{{\bf desc\_\-sequenza} \&}]{s, }
\item[{const {\bf tipo\_\-chiave\_\-t}}]{t}
\end{DoxyParamCaption}
)}}
\label{GSeq_8cc_a98c57942b3eab58c3171251f86b46a97}

\begin{DoxyCode}
{
    s.elementi = new elem_p[DIM_BASE] ;
    s.dim = DIM_BASE ;
    s.num_elem = 0 ;
    s.ordinata = true ;
    s.tipo_chiave = t ;
}
\end{DoxyCode}
\hypertarget{GSeq_8cc_aaf29bed7640205c32dbca4c882027e43}{
\index{GSeq.cc@{GSeq.cc}!inserisci@{inserisci}}
\index{inserisci@{inserisci}!GSeq.cc@{GSeq.cc}}
\subsubsection[{inserisci}]{\setlength{\rightskip}{0pt plus 5cm}void inserisci (
\begin{DoxyParamCaption}
\item[{{\bf desc\_\-sequenza} \&}]{s, }
\item[{{\bf elem} $\ast$}]{el, }
\item[{{\bf ins\_\-modo}}]{modo}
\end{DoxyParamCaption}
)}}
\label{GSeq_8cc_aaf29bed7640205c32dbca4c882027e43}

\begin{DoxyCode}
{
    int pos = 0 ;

    if (modo == in_coda)
        pos = s.num_elem ;
    else if (modo == in_ordine) {
        if (!s.ordinata) {
            cout<<"Inserimento in ordine non effettuato, "
                <<"perché la sequenza non è ordinata"<<endl ;
            return ;
        }
        for ( ; pos < s.num_elem && 
                  diff(s, s.elementi[pos]->chiave, el->chiave) < 0 ;
              pos++)
            ;
    }

    // se non c'e' piu' spazio riallochiamo l'array
    if (s.num_elem == s.dim) {
        elem_p *nuovo = new elem_p[s.dim + DIM_BASE] ;
        for (int i = 0 ; i < s.num_elem ; i++)
            nuovo[i] = s.elementi[i] ;
        delete [] s.elementi ;
        s.elementi = nuovo ;
    }

    for (int i = s.num_elem ; i > pos ; i--)
        s.elementi[i] = s.elementi[i - 1] ;
    
    s.elementi[pos] = el ;
    s.num_elem++ ;

    if (modo != in_ordine && s.num_elem > 1)

        s.ordinata = diff(s, s.elementi[0]->chiave, s.elementi[1]->chiave) < 0 
            && 
            diff(s, s.elementi[s.num_elem-2]->chiave, 
                 s.elementi[s.num_elem - 1]->chiave) < 0 ;
}
\end{DoxyCode}
\hypertarget{GSeq_8cc_ae66f6b31b5ad750f1fe042a706a4e3d4}{
\index{GSeq.cc@{GSeq.cc}!main@{main}}
\index{main@{main}!GSeq.cc@{GSeq.cc}}
\subsubsection[{main}]{\setlength{\rightskip}{0pt plus 5cm}int main (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}
\label{GSeq_8cc_ae66f6b31b5ad750f1fe042a706a4e3d4}

\begin{DoxyCode}
{
    desc_sequenza sequenza ;

    int scelta ;
    do {
        cout<<"Tipo di chiave: "<<endl ;
        cout<<"\t1) Numerica"<<endl ;
        cout<<"\t2) Stringa"<<endl ;
        cin>>scelta ; 
    } while(scelta < 1 || scelta > 2) ;

    tipo_chiave_t tipo_chiave ;
    switch(scelta) {
    case 1: tipo_chiave = CHIAVE_NUMERICA ; break ;
    case 2: tipo_chiave = CHIAVE_STRINGA ; break ;
    default: cout<<"Errore inatteso"<<endl ; return 1 ;
    }

    inizializza(sequenza, tipo_chiave) ;

    char menu[] =
        "\nOpzioni disponibili:\n\n"
        "\t1) Inserisci elemento\n"
        "\t2) Cerca elemento\n"
        "\t3) Elimina elemento\n"
        "\t4) Stampa sequenza\n"
        "\t5) Salva su file\n"
        "\t6) Carica da file\n"
        "\t0) Esci\n"
        "Scelta: " ;

    cout<<"Gestione sequenze."<<endl ;
    while(true) {
        cout<<menu ;

        int scelta ;
        cin>>scelta ;
        if (!cin) {
            cin.clear() ;
            cin.ignore() ;
            continue ;
        }

        switch(scelta) {
        case 0:
            return 0 ;
        case 1:{
            do { 
                cout<<"Modalita' di inserimento:"<<endl ;
                cout<<"\t1) In testa"<<endl ;
                cout<<"\t2) In coda"<<endl ;
                if (sequenza.ordinata)
                    cout<<"\t3) In ordine"<<endl ;
                cin>>scelta ; 
            } while(scelta < 1 || scelta > 3 || 
                    (!sequenza.ordinata && scelta > 2)) ;

            ins_modo modo ;
            switch(scelta) {
            case 1: modo = in_testa ; break ;
            case 2: modo = in_coda ; break ;
            case 3: modo = in_ordine; break ;
            default: cout<<"Errore inatteso"<<endl ; return 1 ;
            }
            elem *el = new elem ;
            el->parole = 0 ;
            cout<<"Dati elemento:"<<endl ;
            cout<<"Chiave: " ;
            cin>>el->chiave ;
            cout<<"Numero di parole: " ;
            cin>>el->num_parole ;
            if (el->num_parole > 0) {
                el->parole = new char[el->num_parole][MAXLUN] ;
                for (int i = 0 ; i < el->num_parole ; i++) {
                    cout<<"Parola: " ;
                    cin>>el->parole[i] ;
                }
            }
            inserisci(sequenza, el, modo) ;}
            break ;
        case 2: {
            char c[MAXLUN] ;
            cout<<"Chiave: " ;
            cin>>c ;
            int pos = cerca(sequenza, c) ;
            if (pos == -1)
                cout<<"Elemento non trovato"<<endl ;
            else {
                cout<<"Elemento trovato: "<<endl ;
                stampa_elem(*sequenza.elementi[pos], cout) ;
            } }
            break ;
        case 3: {
            char c[MAXLUN] ;
            cout<<"Chiave: " ;
            cin>>c ;
            if (!elimina(sequenza, c))
                cout<<"Elemento non trovato"<<endl ;
            else 
                cout<<"Elemento eliminato"<<endl ; }
            break ;
        case 4:
            stampa(sequenza) ;
            break ;
        case 5:
            salva(sequenza, "sequenza.txt") ;
            break ;
        default:
            cout<<"Scelta non valida"<<endl ;
        }
    }

    return 0 ;
}
\end{DoxyCode}
\hypertarget{GSeq_8cc_aa02f6182042c5e23a16f07f93377f0d5}{
\index{GSeq.cc@{GSeq.cc}!ric\_\-binaria@{ric\_\-binaria}}
\index{ric\_\-binaria@{ric\_\-binaria}!GSeq.cc@{GSeq.cc}}
\subsubsection[{ric\_\-binaria}]{\setlength{\rightskip}{0pt plus 5cm}int ric\_\-binaria (
\begin{DoxyParamCaption}
\item[{const {\bf desc\_\-sequenza} \&}]{s, }
\item[{const char}]{c\mbox{[}$\,$\mbox{]}}
\end{DoxyParamCaption}
)}}
\label{GSeq_8cc_aa02f6182042c5e23a16f07f93377f0d5}

\begin{DoxyCode}
{
    if (s.num_elem == 0)
        return -1 ;
    int a = 0, b = s.num_elem - 1, m = (a+b) / 2 ;
    int d ;
    while ((d = diff(s, c, s.elementi[m]->chiave)) != 0) {
        if (d < 0) 
            b = m - 1 ;
        else 
            a = m + 1 ;
        if (a>b) 
            return -1 ;
        m = (a+b) / 2;
    }
    return m ;
}
\end{DoxyCode}
\hypertarget{GSeq_8cc_a7005c15f4f3a9f6040ae5f597d8c1aa8}{
\index{GSeq.cc@{GSeq.cc}!ric\_\-sequenziale@{ric\_\-sequenziale}}
\index{ric\_\-sequenziale@{ric\_\-sequenziale}!GSeq.cc@{GSeq.cc}}
\subsubsection[{ric\_\-sequenziale}]{\setlength{\rightskip}{0pt plus 5cm}int ric\_\-sequenziale (
\begin{DoxyParamCaption}
\item[{const {\bf desc\_\-sequenza} \&}]{s, }
\item[{const char}]{c\mbox{[}$\,$\mbox{]}}
\end{DoxyParamCaption}
)}}
\label{GSeq_8cc_a7005c15f4f3a9f6040ae5f597d8c1aa8}

\begin{DoxyCode}
{
    int pos ;
    for (pos = 0 ; pos < s.num_elem ; pos++)
        if (diff(s, s.elementi[pos]->chiave, c) == 0)
            return pos ;
    return -1 ;
}
\end{DoxyCode}
\hypertarget{GSeq_8cc_a32b85d9151974c75590269537470fc55}{
\index{GSeq.cc@{GSeq.cc}!salva@{salva}}
\index{salva@{salva}!GSeq.cc@{GSeq.cc}}
\subsubsection[{salva}]{\setlength{\rightskip}{0pt plus 5cm}void salva (
\begin{DoxyParamCaption}
\item[{const {\bf desc\_\-sequenza} \&}]{s, }
\item[{const char}]{nome\mbox{[}$\,$\mbox{]}}
\end{DoxyParamCaption}
)}}
\label{GSeq_8cc_a32b85d9151974c75590269537470fc55}

\begin{DoxyCode}
{
    ofstream f(nome) ;
    for (int i = 0 ; i < s.num_elem ; i++)
        stampa_elem(*s.elementi[i], f);
}
\end{DoxyCode}
\hypertarget{GSeq_8cc_aff0ea94992a6e54aec947cd7ffe0efc2}{
\index{GSeq.cc@{GSeq.cc}!stampa@{stampa}}
\index{stampa@{stampa}!GSeq.cc@{GSeq.cc}}
\subsubsection[{stampa}]{\setlength{\rightskip}{0pt plus 5cm}void stampa (
\begin{DoxyParamCaption}
\item[{const {\bf desc\_\-sequenza} \&}]{s}
\end{DoxyParamCaption}
)}}
\label{GSeq_8cc_aff0ea94992a6e54aec947cd7ffe0efc2}

\begin{DoxyCode}
{
    for (int i = 0 ; i < s.num_elem ; i++) {
        cout<<"Elemento "<<i<<":"<<endl<<'\t' ;
        stampa_elem(*s.elementi[i], cout);
    }
    
    cout<<endl<<"Numero di elementi: "<<s.num_elem<<endl ;
    cout<<"Dimensione array: "<<s.dim<<endl ;
    cout<<(s.ordinata ? "Sequenza ordinata" : "Sequenza non ordinata")<<endl ;
}
\end{DoxyCode}
\hypertarget{GSeq_8cc_a2dad0010e500c42f05ae58bff0ca0b76}{
\index{GSeq.cc@{GSeq.cc}!stampa\_\-elem@{stampa\_\-elem}}
\index{stampa\_\-elem@{stampa\_\-elem}!GSeq.cc@{GSeq.cc}}
\subsubsection[{stampa\_\-elem}]{\setlength{\rightskip}{0pt plus 5cm}void stampa\_\-elem (
\begin{DoxyParamCaption}
\item[{const {\bf elem} \&}]{el, }
\item[{ostream \&}]{os}
\end{DoxyParamCaption}
)}}
\label{GSeq_8cc_a2dad0010e500c42f05ae58bff0ca0b76}

\begin{DoxyCode}
{
    os<<el.chiave ;
    for (int i = 0 ; i < el.num_parole ; i++)
        os<<" "<<el.parole[i] ;
    os<<endl ;
}
\end{DoxyCode}


\subsection{Variable Documentation}
\hypertarget{GSeq_8cc_aca05eea8d265284324bd4e8418a81508}{
\index{GSeq.cc@{GSeq.cc}!DIM\_\-BASE@{DIM\_\-BASE}}
\index{DIM\_\-BASE@{DIM\_\-BASE}!GSeq.cc@{GSeq.cc}}
\subsubsection[{DIM\_\-BASE}]{\setlength{\rightskip}{0pt plus 5cm}const int {\bf DIM\_\-BASE} = 100}}
\label{GSeq_8cc_aca05eea8d265284324bd4e8418a81508}
\hypertarget{GSeq_8cc_ae68bf5715a32605dee2ba5beeb81fd66}{
\index{GSeq.cc@{GSeq.cc}!MAXLUN@{MAXLUN}}
\index{MAXLUN@{MAXLUN}!GSeq.cc@{GSeq.cc}}
\subsubsection[{MAXLUN}]{\setlength{\rightskip}{0pt plus 5cm}const int {\bf MAXLUN} = 100}}
\label{GSeq_8cc_ae68bf5715a32605dee2ba5beeb81fd66}
