\hypertarget{class_qore_1_1_hash_key_iterator}{}\doxysection{Qore\+::Hash\+Key\+Iterator Class Reference}
\label{class_qore_1_1_hash_key_iterator}\index{Qore::HashKeyIterator@{Qore::HashKeyIterator}}


This class an iterator class for hashes.  




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



Inheritance diagram for Qore\+::Hash\+Key\+Iterator\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{class_qore_1_1_hash_key_iterator__inherit__graph}
\end{center}
\end{figure}
\doxysubsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{class_qore_1_1_hash_key_iterator_ab9e4ca503cde5b869a74083bdbb8fc82}{constructor}} (\mbox{\hyperlink{group__type__conversion__functions_ga24ee71727f0785d3b826833ed6f5e2ee}{hash}}$<$ auto $>$ h)
\begin{DoxyCompactList}\small\item\em Creates the hash iterator object. \end{DoxyCompactList}\item 
\mbox{\hyperlink{class_qore_1_1_hash_key_iterator_a2beecc3000b38c19040cdac2ca231010}{constructor}} ()
\begin{DoxyCompactList}\small\item\em Creates an empty hash iterator object. \end{DoxyCompactList}\item 
\mbox{\hyperlink{class_qore_1_1_hash_key_iterator_a73d638a807b18508de09e680b6ac5faa}{copy}} ()
\begin{DoxyCompactList}\small\item\em Creates a copy of the \mbox{\hyperlink{class_qore_1_1_hash_key_iterator}{Hash\+Key\+Iterator}} object, iterating the same object as the original and in the same position. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}} \mbox{\hyperlink{class_qore_1_1_hash_key_iterator_a749d9db18178ea1f86aa721b3c37a770}{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}\end{DoxyCompactItemize}


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

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

\begin{DoxyParagraph}{Example\+: Hash\+Key\+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{HashKeyIterator it(data);}
\DoxyCodeLine{\textcolor{keywordflow}{while} (it.next()) \{}
\DoxyCodeLine{    printf(\textcolor{stringliteral}{"{}iter: \%n\(\backslash\)n"{}}, it.getValue());}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{iter: \textcolor{stringliteral}{"{}key1"{}}}
\DoxyCodeLine{iter: \textcolor{stringliteral}{"{}key2"{}}}
\DoxyCodeLine{iter: \textcolor{stringliteral}{"{}key3"{}}}

\end{DoxyCode}

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

\begin{DoxyItemize}
\item In general, the \mbox{\hyperlink{class_qore_1_1_hash_key_iterator}{Hash\+Key\+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}
\mbox{\hyperlink{class_qore_1_1_hash_key_reverse_iterator}{Hash\+Key\+Reverse\+Iterator}} 
\end{DoxySeeAlso}


\doxysubsection{Member Function Documentation}
\mbox{\Hypertarget{class_qore_1_1_hash_key_iterator_a2beecc3000b38c19040cdac2ca231010}\label{class_qore_1_1_hash_key_iterator_a2beecc3000b38c19040cdac2ca231010}} 
\index{Qore::HashKeyIterator@{Qore::HashKeyIterator}!constructor@{constructor}}
\index{constructor@{constructor}!Qore::HashKeyIterator@{Qore::HashKeyIterator}}
\doxysubsubsection{\texorpdfstring{constructor()}{constructor()}\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily Qore\+::\+Hash\+Key\+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{HashKeyIterator hi(h);}

\end{DoxyCode}
 
\end{DoxyParagraph}
\mbox{\Hypertarget{class_qore_1_1_hash_key_iterator_ab9e4ca503cde5b869a74083bdbb8fc82}\label{class_qore_1_1_hash_key_iterator_ab9e4ca503cde5b869a74083bdbb8fc82}} 
\index{Qore::HashKeyIterator@{Qore::HashKeyIterator}!constructor@{constructor}}
\index{constructor@{constructor}!Qore::HashKeyIterator@{Qore::HashKeyIterator}}
\doxysubsubsection{\texorpdfstring{constructor()}{constructor()}\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily Qore\+::\+Hash\+Key\+Iterator\+::constructor (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__type__conversion__functions_ga24ee71727f0785d3b826833ed6f5e2ee}{hash}}$<$ 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{HashKeyIterator hi(h);}

\end{DoxyCode}
 
\end{DoxyParagraph}
\mbox{\Hypertarget{class_qore_1_1_hash_key_iterator_a73d638a807b18508de09e680b6ac5faa}\label{class_qore_1_1_hash_key_iterator_a73d638a807b18508de09e680b6ac5faa}} 
\index{Qore::HashKeyIterator@{Qore::HashKeyIterator}!copy@{copy}}
\index{copy@{copy}!Qore::HashKeyIterator@{Qore::HashKeyIterator}}
\doxysubsubsection{\texorpdfstring{copy()}{copy()}}
{\footnotesize\ttfamily Qore\+::\+Hash\+Key\+Iterator\+::copy (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})}



Creates a copy of the \mbox{\hyperlink{class_qore_1_1_hash_key_iterator}{Hash\+Key\+Iterator}} object, iterating the same object as the original and in the same position. 

\begin{DoxyParagraph}{Example\+:}

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

\end{DoxyCode}
 
\end{DoxyParagraph}
\mbox{\Hypertarget{class_qore_1_1_hash_key_iterator_a749d9db18178ea1f86aa721b3c37a770}\label{class_qore_1_1_hash_key_iterator_a749d9db18178ea1f86aa721b3c37a770}} 
\index{Qore::HashKeyIterator@{Qore::HashKeyIterator}!getValue@{getValue}}
\index{getValue@{getValue}!Qore::HashKeyIterator@{Qore::HashKeyIterator}}
\doxysubsubsection{\texorpdfstring{getValue()}{getValue()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__type__conversion__functions_gacf16b4126b795f4b6933ef3425cadae3}{string}} Qore\+::\+Hash\+Key\+Iterator\+::get\+Value (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [virtual]}}



returns the current key value or throws an {\ttfamily INVALID-\/\+ITERATOR} exception if the iterator is invalid 

\begin{DoxyReturn}{Returns}
the current key value or throws an {\ttfamily INVALID-\/\+ITERATOR} exception if the iterator is invalid
\end{DoxyReturn}
\begin{DoxyParagraph}{Code Flags\+:}
\mbox{\hyperlink{code_flags_RET_VALUE_ONLY}{RET\+\_\+\+VALUE\+\_\+\+ONLY}}
\end{DoxyParagraph}
\begin{DoxyParagraph}{Example\+:}

\begin{DoxyCode}{0}
\DoxyCodeLine{foreach string key \textcolor{keywordflow}{in} (hash.keyIterator())}
\DoxyCodeLine{    printf(\textcolor{stringliteral}{"{}key: \%s\(\backslash\)n"{}}, key);}

\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}


Reimplemented from \mbox{\hyperlink{class_qore_1_1_hash_iterator_ac476d576e747b685d4284fb02a5cf83e}{Qore\+::\+Hash\+Iterator}}.

