\hypertarget{class_qore_1_1_hash_pair_iterator}{}\doxysection{Qore\+::Hash\+Pair\+Iterator Class Reference} \label{class_qore_1_1_hash_pair_iterator}\index{Qore::HashPairIterator@{Qore::HashPairIterator}} This class an iterator class for hashes. Inheritance diagram for Qore\+::Hash\+Pair\+Iterator\+: % FIG 0 \doxysubsection*{Public Member Functions} \begin{DoxyCompactItemize} \item \mbox{\hyperlink{class_qore_1_1_hash_pair_iterator_a6bf6fbf5b0ff51abda6a141c2c209f6e}{constructor}} (\mbox{\hyperlink{group__type__conversion__functions_ga0231dbb472dd230310af7c7c34f56e92}{hash}}$<$ auto $>$ 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 \mbox{\hyperlink{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_ga0231dbb472dd230310af7c7c34f56e92}{hash}}$<$ auto $>$ \mbox{\hyperlink{class_qore_1_1_hash_pair_iterator_a7fbbc6dd431b481042d49eeb706b871e}{get\+Value}} () \begin{DoxyCompactList}\small\item\em returns a hash with the current key and value (a hash with 2 keys\+: {\ttfamily \char`\"{}key\char`\"{}} and {\ttfamily \char`\"{}value\char`\"{}}) 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_hash_iterator_ae1c8221cd1002edbb93ec41a333900ae}{Hash\+Pair\+Iterator\+::next()}} to iterate through the hash; do not use the iterator if \mbox{\hyperlink{class_qore_1_1_hash_iterator_ae1c8221cd1002edbb93ec41a333900ae}{Hash\+Pair\+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_hash_iterator_a9df83a19c89100056c875b2ca40f6ed3}{Hash\+Pair\+Iterator\+::prev()}} instead of \mbox{\hyperlink{class_qore_1_1_hash_iterator_ae1c8221cd1002edbb93ec41a333900ae}{Hash\+Pair\+Iterator\+::next()}} \begin{DoxyParagraph}{Example\+: Hash\+Pair\+Iterator basic usage} \begin{DoxyCode}{0} \DoxyCodeLine{hash 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{ \mbox{\hyperlink{group__string__functions_ga32070517a9f8a70a32ef48f83a6f128e}{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 \mbox{\hyperlink{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} \mbox{\hyperlink{class_qore_1_1_hash_pair_reverse_iterator}{Hash\+Pair\+Reverse\+Iterator}} \end{DoxySeeAlso} \doxysubsection{Member Function Documentation} \mbox{\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 h = get\_hash\_or\_nothing();} \DoxyCodeLine{HashPairIterator hi(h);} \end{DoxyCode} \end{DoxyParagraph} \mbox{\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_ga0231dbb472dd230310af7c7c34f56e92}{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{HashPairIterator hi(h);} \end{DoxyCode} \end{DoxyParagraph} \mbox{\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 \mbox{\hyperlink{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} \mbox{\Hypertarget{class_qore_1_1_hash_pair_iterator_a7fbbc6dd431b481042d49eeb706b871e}\label{class_qore_1_1_hash_pair_iterator_a7fbbc6dd431b481042d49eeb706b871e}} \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_ga0231dbb472dd230310af7c7c34f56e92}{hash}}$<$auto$>$ Qore\+::\+Hash\+Pair\+Iterator\+::get\+Value (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [virtual]}} returns a hash with the current key and value (a hash with 2 keys\+: {\ttfamily \char`\"{}key\char`\"{}} and {\ttfamily \char`\"{}value\char`\"{}}) 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 \char`\"{}key\char`\"{}} and {\ttfamily \char`\"{}value\char`\"{}}) 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{map \mbox{\hyperlink{group__string__functions_ga32070517a9f8a70a32ef48f83a6f128e}{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} Reimplemented from \mbox{\hyperlink{class_qore_1_1_hash_iterator_ac476d576e747b685d4284fb02a5cf83e}{Qore\+::\+Hash\+Iterator}}.