\doxysection{Qore\+::Hash\+Pair\+Iterator Class Reference}
\hypertarget{class_qore_1_1_hash_pair_iterator}{}\label{class_qore_1_1_hash_pair_iterator}\index{Qore::HashPairIterator@{Qore::HashPairIterator}}


This class an iterator class for hashes.  




{\ttfamily \#include $<$QC\+\_\+\+Hash\+Pair\+Iterator.\+dox.\+h$>$}



Inheritance diagram for Qore\+::Hash\+Pair\+Iterator\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{class_qore_1_1_hash_pair_iterator__inherit__graph}
\end{center}
\end{figure}
\doxysubsubsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{class_qore_1_1_hash_pair_iterator_a6bf6fbf5b0ff51abda6a141c2c209f6e}{constructor}} (\mbox{\hyperlink{group__type__conversion__functions_ga24ee71727f0785d3b826833ed6f5e2ee}{hash}}$<$ \mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{auto}} $>$ \mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{h}})
\begin{DoxyCompactList}\small\item\em Creates the hash iterator object. \end{DoxyCompactList}\item 
\mbox{\hyperlink{class_qore_1_1_hash_pair_iterator_acc8fc5c450a9972105ec005279df6b91}{constructor}} ()
\begin{DoxyCompactList}\small\item\em Creates an empty hash iterator object. \end{DoxyCompactList}\item 
\mbox{\hyperlink{class_qore_1_1_hash_pair_iterator_a0f73dec0ab37533fa037751645d3132f}{copy}} ()
\begin{DoxyCompactList}\small\item\em Creates a copy of the \doxylink{class_qore_1_1_hash_pair_iterator}{Hash\+Pair\+Iterator} object, iterating the same object as the original and in the same position. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga24ee71727f0785d3b826833ed6f5e2ee}{hash}}$<$ \mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{auto}} $>$ \mbox{\hyperlink{class_qore_1_1_hash_pair_iterator_a1b49bc45a3272888838cd4e1fbd0c279}{get\+Value}} ()
\begin{DoxyCompactList}\small\item\em returns a hash with the current key and value (a hash with 2 keys\+: {\ttfamily "{}key"{}} and {\ttfamily "{}value"{}}) or throws an {\ttfamily INVALID-\/\+ITERATOR} exception if the iterator is invalid \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Public Member Functions inherited from \mbox{\hyperlink{class_qore_1_1_hash_iterator}{Qore\+::\+Hash\+Iterator}}}
\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{class_qore_1_1_hash_iterator_a842d257239bb77f2989960dbe1ddabc9}{constructor}} (\mbox{\hyperlink{group__type__conversion__functions_ga24ee71727f0785d3b826833ed6f5e2ee}{hash}}$<$ \mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{auto}} $>$ \mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{h}})
\begin{DoxyCompactList}\small\item\em Creates the hash iterator object. \end{DoxyCompactList}\item 
\mbox{\hyperlink{class_qore_1_1_hash_iterator_a1fc56abc6eb066009a390ff11fe5b69d}{constructor}} ()
\begin{DoxyCompactList}\small\item\em Creates an empty hash iterator object. \end{DoxyCompactList}\item 
\mbox{\hyperlink{class_qore_1_1_hash_iterator_ae35efa6b6afd35bc56fdddd9d5622059}{copy}} ()
\begin{DoxyCompactList}\small\item\em Creates a copy of the \doxylink{class_qore_1_1_hash_iterator}{Hash\+Iterator} object, iterating the same object as the original and in the same position. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{bool}} \mbox{\hyperlink{class_qore_1_1_hash_iterator_adc2400ed775808e5ab8a3afd671c4428}{empty}} ()
\begin{DoxyCompactList}\small\item\em returns \doxysectlink{basic_data_types_True}{True}{2} if the hash is empty; \doxysectlink{basic_data_types_False}{False}{2} if not \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{bool}} \mbox{\hyperlink{class_qore_1_1_hash_iterator_a1d639332a9f27f97a830994b1a68ada2}{first}} ()
\begin{DoxyCompactList}\small\item\em returns \doxysectlink{basic_data_types_True}{True}{2} if on the first element of the hash \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}} \mbox{\hyperlink{class_qore_1_1_hash_iterator_a60c35d8ea159a1f9b53c0b164094c7c0}{get\+Key}} ()
\begin{DoxyCompactList}\small\item\em returns the current key value or throws an {\ttfamily INVALID-\/\+ITERATOR} exception if the iterator is invalid \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{auto}} \mbox{\hyperlink{class_qore_1_1_hash_iterator_a0d62ed2e642f1f9f0fc06cbd2d79b14b}{get\+Key\+Value}} ()
\begin{DoxyCompactList}\small\item\em returns the current value of the current hash key being iterated or throws an {\ttfamily INVALID-\/\+ITERATOR} exception if the iterator is invalid \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{auto}} \mbox{\hyperlink{class_qore_1_1_hash_iterator_ac476d576e747b685d4284fb02a5cf83e}{get\+Value}} ()
\begin{DoxyCompactList}\small\item\em returns the current key value or throws an {\ttfamily INVALID-\/\+ITERATOR} exception if the iterator is invalid \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga24ee71727f0785d3b826833ed6f5e2ee}{hash}}$<$ \mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{auto}} $>$ \mbox{\hyperlink{class_qore_1_1_hash_iterator_aefac138e6e464a1c71b2ac15d0b0569e}{get\+Value\+Pair}} ()
\begin{DoxyCompactList}\small\item\em returns a hash with the current key and value (a hash with 2 keys\+: {\ttfamily "{}key"{}} and {\ttfamily "{}value"{}}) or throws an {\ttfamily INVALID-\/\+ITERATOR} exception if the iterator is invalid \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{bool}} \mbox{\hyperlink{class_qore_1_1_hash_iterator_a40b7935be4791e186dba782e091084e5}{last}} ()
\begin{DoxyCompactList}\small\item\em returns \doxysectlink{basic_data_types_True}{True}{2} if on the last element of the hash \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{bool}} \mbox{\hyperlink{class_qore_1_1_hash_iterator_ae1c8221cd1002edbb93ec41a333900ae}{next}} ()
\begin{DoxyCompactList}\small\item\em Moves the current position to the next element in the hash; returns \doxysectlink{basic_data_types_False}{False}{2} if there are no more elements; if the iterator is not pointing at a valid element before this call, the iterator will be positioned on the first element in the hash if the hash is not empty. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{bool}} \mbox{\hyperlink{class_qore_1_1_hash_iterator_a9df83a19c89100056c875b2ca40f6ed3}{prev}} ()
\begin{DoxyCompactList}\small\item\em Moves the current position to the previous element in the hash; returns \doxysectlink{basic_data_types_False}{False}{2} if there are no more elements; if the iterator is not pointing at a valid element before this call, the iterator will be positioned on the last element in the hash if the hash is not empty. \end{DoxyCompactList}\item 
\mbox{\hyperlink{class_qore_1_1_hash_iterator_ad7b5c2e35ee739f1ef3cbe9565f075ad}{reset}} ()
\begin{DoxyCompactList}\small\item\em Reset the iterator instance to its initial state. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{bool}} \mbox{\hyperlink{class_qore_1_1_hash_iterator_a12d469ed0e4ba8b61b8a38fa97332ef1}{valid}} ()
\begin{DoxyCompactList}\small\item\em returns \doxysectlink{basic_data_types_True}{True}{2} if the iterator is currently pointing at a valid element, \doxysectlink{basic_data_types_False}{False}{2} if not \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Public Member Functions inherited from \mbox{\hyperlink{class_qore_1_1_abstract_bidirectional_iterator}{Qore\+::\+Abstract\+Bidirectional\+Iterator}}}
\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{abstract}} \mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{bool}} \mbox{\hyperlink{class_qore_1_1_abstract_bidirectional_iterator_a8ca43ac8bffc78178f61e3cca9b6323e}{prev}} ()
\begin{DoxyCompactList}\small\item\em Moves the current position to the previous element; returns \doxysectlink{basic_data_types_False}{False}{2} if there are no more elements. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Public Member Functions inherited from \mbox{\hyperlink{class_qore_1_1_abstract_iterator}{Qore\+::\+Abstract\+Iterator}}}
\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{abstract}} \mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{auto}} \mbox{\hyperlink{class_qore_1_1_abstract_iterator_aa01374b285003faa21b045082063ac12}{get\+Value}} ()
\begin{DoxyCompactList}\small\item\em returns the current value \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{abstract}} \mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{bool}} \mbox{\hyperlink{class_qore_1_1_abstract_iterator_ab10d5694cc2fcd3b6689ea7494da79de}{next}} ()
\begin{DoxyCompactList}\small\item\em Moves the current position to the next element; returns \doxysectlink{basic_data_types_False}{False}{2} if there are no more elements. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{abstract}} \mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{bool}} \mbox{\hyperlink{class_qore_1_1_abstract_iterator_aee1def5d872b487b8917a166d9b263e8}{valid}} ()
\begin{DoxyCompactList}\small\item\em returns \doxysectlink{basic_data_types_True}{True}{2} if the iterator is currently pointing at a valid element, \doxysectlink{basic_data_types_False}{False}{2} if not \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Public Member Functions inherited from \mbox{\hyperlink{class_qore_1_1_abstract_quantified_iterator}{Qore\+::\+Abstract\+Quantified\+Iterator}}}
\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{abstract}} \mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{bool}} \mbox{\hyperlink{class_qore_1_1_abstract_quantified_iterator_aa859f2f4a719f955b100cde8b65b3277}{empty}} ()
\begin{DoxyCompactList}\small\item\em returns \doxysectlink{basic_data_types_True}{True}{2} if the object to iterate is empty; \doxysectlink{basic_data_types_False}{False}{2} if not \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{abstract}} \mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{bool}} \mbox{\hyperlink{class_qore_1_1_abstract_quantified_iterator_a4264e42010fa08a8099692e2876c3241}{first}} ()
\begin{DoxyCompactList}\small\item\em returns \doxysectlink{basic_data_types_True}{True}{2} if on the first element \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{abstract}} \mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{bool}} \mbox{\hyperlink{class_qore_1_1_abstract_quantified_iterator_aa7bef0cd843ced4319fd5f0d7647ef8e}{last}} ()
\begin{DoxyCompactList}\small\item\em returns \doxysectlink{basic_data_types_True}{True}{2} if on the last element \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
This class an iterator class for hashes. 

Call \doxylink{class_qore_1_1_abstract_iterator_ab10d5694cc2fcd3b6689ea7494da79de}{Hash\+Pair\+Iterator\+::next()} to iterate through the hash; do not use the iterator if \doxylink{class_qore_1_1_abstract_iterator_ab10d5694cc2fcd3b6689ea7494da79de}{Hash\+Pair\+Iterator\+::next()} returns \doxysectlink{basic_data_types_False}{False}{2}. A hash can be iterated in reverse order by calling \doxylink{class_qore_1_1_abstract_bidirectional_iterator_a8ca43ac8bffc78178f61e3cca9b6323e}{Hash\+Pair\+Iterator\+::prev()} instead of \doxylink{class_qore_1_1_abstract_iterator_ab10d5694cc2fcd3b6689ea7494da79de}{Hash\+Pair\+Iterator\+::next()}

\begin{DoxyParagraph}{Example\+: Hash\+Pair\+Iterator basic usage}

\begin{DoxyCode}{0}
\DoxyCodeLine{hash<auto>\ data\ =\ \{}
\DoxyCodeLine{\ \ \ \ \textcolor{stringliteral}{"{}key1"{}}\ :\ 1,}
\DoxyCodeLine{\ \ \ \ \textcolor{stringliteral}{"{}key2"{}}\ :\ 2,}
\DoxyCodeLine{\ \ \ \ \textcolor{stringliteral}{"{}key3"{}}\ :\ 3,}
\DoxyCodeLine{\};}
\DoxyCodeLine{}
\DoxyCodeLine{HashPairIterator\ it(data);}
\DoxyCodeLine{\textcolor{keywordflow}{while}\ (it.next())\ \{}
\DoxyCodeLine{\ \ \ \ printf(\textcolor{stringliteral}{"{}iter:\ \%n\(\backslash\)n"{}},\ it.getValue());}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{iter:\ hash:\ (key\ :\ \textcolor{stringliteral}{"{}key1"{}},\ value\ :\ 1)}
\DoxyCodeLine{iter:\ hash:\ (key\ :\ \textcolor{stringliteral}{"{}key2"{}},\ value\ :\ 2)}
\DoxyCodeLine{iter:\ hash:\ (key\ :\ \textcolor{stringliteral}{"{}key3"{}},\ value\ :\ 3)}

\end{DoxyCode}

\end{DoxyParagraph}
\begin{DoxyNote}{Note}

\begin{DoxyItemize}
\item In general, the \doxylink{class_qore_1_1_hash_pair_iterator}{Hash\+Pair\+Iterator} class is not designed to be accessed from multiple threads; it was created without locking for fast and efficient use when used from a single thread. For methods that would be unsafe to use in another thread, any use of such methods in threads other than the thread where the constructor was called will cause an {\ttfamily ITERATOR-\/\+THREAD-\/\+ERROR} to be thrown.
\end{DoxyItemize}
\end{DoxyNote}
\begin{DoxySeeAlso}{See also}
\doxylink{class_qore_1_1_hash_pair_reverse_iterator}{Hash\+Pair\+Reverse\+Iterator} 
\end{DoxySeeAlso}


\doxysubsection{Member Function Documentation}
\Hypertarget{class_qore_1_1_hash_pair_iterator_acc8fc5c450a9972105ec005279df6b91}\label{class_qore_1_1_hash_pair_iterator_acc8fc5c450a9972105ec005279df6b91} 
\index{Qore::HashPairIterator@{Qore::HashPairIterator}!constructor@{constructor}}
\index{constructor@{constructor}!Qore::HashPairIterator@{Qore::HashPairIterator}}
\doxysubsubsection{\texorpdfstring{constructor()}{constructor()}\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily Qore\+::\+Hash\+Pair\+Iterator\+::constructor (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



Creates an empty hash iterator object. 

\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}{0}
\DoxyCodeLine{*hash<auto>\ h\ =\ get\_hash\_or\_nothing();}
\DoxyCodeLine{HashPairIterator\ hi(h);}

\end{DoxyCode}
 
\end{DoxyParagraph}
\Hypertarget{class_qore_1_1_hash_pair_iterator_a6bf6fbf5b0ff51abda6a141c2c209f6e}\label{class_qore_1_1_hash_pair_iterator_a6bf6fbf5b0ff51abda6a141c2c209f6e} 
\index{Qore::HashPairIterator@{Qore::HashPairIterator}!constructor@{constructor}}
\index{constructor@{constructor}!Qore::HashPairIterator@{Qore::HashPairIterator}}
\doxysubsubsection{\texorpdfstring{constructor()}{constructor()}\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily Qore\+::\+Hash\+Pair\+Iterator\+::constructor (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__type__conversion__functions_ga24ee71727f0785d3b826833ed6f5e2ee}{hash}}$<$ \mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{auto}} $>$}]{h }\end{DoxyParamCaption})}



Creates the hash iterator object. 


\begin{DoxyParams}{Parameters}
{\em h} & the hash to iterate\\
\hline
\end{DoxyParams}
\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}{0}
\DoxyCodeLine{HashPairIterator\ hi(h);}

\end{DoxyCode}
 
\end{DoxyParagraph}
\Hypertarget{class_qore_1_1_hash_pair_iterator_a0f73dec0ab37533fa037751645d3132f}\label{class_qore_1_1_hash_pair_iterator_a0f73dec0ab37533fa037751645d3132f} 
\index{Qore::HashPairIterator@{Qore::HashPairIterator}!copy@{copy}}
\index{copy@{copy}!Qore::HashPairIterator@{Qore::HashPairIterator}}
\doxysubsubsection{\texorpdfstring{copy()}{copy()}}
{\footnotesize\ttfamily Qore\+::\+Hash\+Pair\+Iterator\+::copy (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



Creates a copy of the \doxylink{class_qore_1_1_hash_pair_iterator}{Hash\+Pair\+Iterator} object, iterating the same object as the original and in the same position. 

\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}{0}
\DoxyCodeLine{HashPairIterator\ ni\ =\ i.copy();}

\end{DoxyCode}
 
\end{DoxyParagraph}
\Hypertarget{class_qore_1_1_hash_pair_iterator_a1b49bc45a3272888838cd4e1fbd0c279}\label{class_qore_1_1_hash_pair_iterator_a1b49bc45a3272888838cd4e1fbd0c279} 
\index{Qore::HashPairIterator@{Qore::HashPairIterator}!getValue@{getValue}}
\index{getValue@{getValue}!Qore::HashPairIterator@{Qore::HashPairIterator}}
\doxysubsubsection{\texorpdfstring{getValue()}{getValue()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_ga24ee71727f0785d3b826833ed6f5e2ee}{hash}}$<$ \mbox{\hyperlink{group__type__conversion__functions_ga9a401e5112c58f63c05e7ee1e15968ef}{auto}} $>$ Qore\+::\+Hash\+Pair\+Iterator\+::get\+Value (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



returns a hash with the current key and value (a hash with 2 keys\+: {\ttfamily "{}key"{}} and {\ttfamily "{}value"{}}) or throws an {\ttfamily INVALID-\/\+ITERATOR} exception if the iterator is invalid 

\begin{DoxyReturn}{Returns}
a hash with the current key and value (a hash with 2 keys\+: {\ttfamily "{}key"{}} and {\ttfamily "{}value"{}}) or throws an {\ttfamily INVALID-\/\+ITERATOR} exception if the iterator is invalid
\end{DoxyReturn}
\begin{DoxyParagraph}{Code Flags\+:}
\doxysectlink{code_flags_RET_VALUE_ONLY}{RET\+\_\+\+VALUE\+\_\+\+ONLY}{1}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}{0}
\DoxyCodeLine{map\ printf(\textcolor{stringliteral}{"{}\%s:\ \%y\(\backslash\)n"{}},\ \$1.key,\ \$1.value),\ hash.pairIterator();}

\end{DoxyCode}

\end{DoxyParagraph}

\begin{DoxyExceptions}{Exceptions}
{\em INVALID-\/\+ITERATOR} & the iterator is not pointing at a valid element \\
\hline
{\em ITERATOR-\/\+THREAD-\/\+ERROR} & this exception is thrown if this method is called from any thread other than the thread that created the object\\
\hline
\end{DoxyExceptions}
\begin{DoxySince}{Since}
Qore 0.\+8.\+6.\+2 
\end{DoxySince}
