\hypertarget{classkdb_1_1KeySet}{\section{kdb\-:\-:Key\-Set Class Reference}
\label{classkdb_1_1KeySet}\index{kdb\-::\-Key\-Set@{kdb\-::\-Key\-Set}}
}


A keyset holds together a set of keys.  




{\ttfamily \#include $<$keyset.\-hpp$>$}

\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{Key\-Set} ()
\begin{DoxyCompactList}\small\item\em \end{DoxyCompactList}\item 
\hyperlink{classkdb_1_1KeySet_a21f651ff310178951402038e590743e0}{Key\-Set} (ckdb\-::\-Key\-Set $\ast$k)
\item 
\hyperlink{classkdb_1_1KeySet_ad8d6df839ab852fded1739ff3398d0b1}{Key\-Set} (const \hyperlink{classkdb_1_1KeySet}{Key\-Set} \&other)
\item 
\hyperlink{classkdb_1_1KeySet_abd9c4225de42a465621e7e9f6bd06d70}{Key\-Set} (size\-\_\-t alloc, va\-\_\-list ap)
\begin{DoxyCompactList}\small\item\em Create a new keyset. \end{DoxyCompactList}\item 
\hyperlink{classkdb_1_1KeySet_ab4bb5ec4e73eca8ea1bd0a843a6489d4}{Key\-Set} (size\-\_\-t alloc,...)
\begin{DoxyCompactList}\small\item\em Create a new keyset. \end{DoxyCompactList}\item 
\hyperlink{classkdb_1_1KeySet_ade654f92bddec24abad1b651e828f2b8}{$\sim$\-Key\-Set} ()
\begin{DoxyCompactList}\small\item\em Deconstruct a keyset. \end{DoxyCompactList}\item 
ckdb\-::\-Key\-Set $\ast$ \hyperlink{classkdb_1_1KeySet_a2987b3fb1b12196399650726f1c18f02}{release} ()
\item 
ckdb\-::\-Key\-Set $\ast$ \hyperlink{classkdb_1_1KeySet_aa79bbbfb6e2f3e9c48cb3e595f9cda51}{get\-Key\-Set} () const 
\begin{DoxyCompactList}\small\item\em Passes out the raw keyset pointer. \end{DoxyCompactList}\item 
void \hyperlink{classkdb_1_1KeySet_a9f3ec4eebe304185527b08a6fa01b77c}{set\-Key\-Set} (ckdb\-::\-Key\-Set $\ast$k)
\begin{DoxyCompactList}\small\item\em Take ownership of passed keyset. \end{DoxyCompactList}\item 
\hyperlink{classkdb_1_1KeySet}{Key\-Set} \& \hyperlink{classkdb_1_1KeySet_a1c54736b7206bc2253d02a5bf4b3ccfb}{operator=} (\hyperlink{classkdb_1_1KeySet}{Key\-Set} const \&other)
\item 
ssize\-\_\-t \hyperlink{classkdb_1_1KeySet_a18b332fe23a7f793f80f9b22b5727584}{size} () const 
\begin{DoxyCompactList}\small\item\em The size of the keyset. \end{DoxyCompactList}\item 
ckdb\-::\-Key\-Set $\ast$ \hyperlink{classkdb_1_1KeySet_a72d0b50194fb1900c468b53e749369a2}{dup} () const 
\begin{DoxyCompactList}\small\item\em Duplicate a keyset. \end{DoxyCompactList}\item 
void \hyperlink{classkdb_1_1KeySet_a28fd33fdaecf1d57d4dddac7058f5d38}{copy} (const \hyperlink{classkdb_1_1KeySet}{Key\-Set} \&other)
\begin{DoxyCompactList}\small\item\em Copy a keyset. \end{DoxyCompactList}\item 
void \hyperlink{classkdb_1_1KeySet_a38f5159e39758aa632421d2fe7440633}{clear} ()
\begin{DoxyCompactList}\small\item\em Clear the keyset. \end{DoxyCompactList}\item 
ssize\-\_\-t \hyperlink{classkdb_1_1KeySet_a0d4b2f3aa9f58d10053561135b50233e}{append} (const \hyperlink{classkdb_1_1Key}{Key} \&to\-Append)
\begin{DoxyCompactList}\small\item\em append a key \end{DoxyCompactList}\item 
ssize\-\_\-t \hyperlink{classkdb_1_1KeySet_ac9cbdc933d7171037d47c6d4d78595d1}{append} (const \hyperlink{classkdb_1_1KeySet}{Key\-Set} \&to\-Append)
\begin{DoxyCompactList}\small\item\em append a keyset \end{DoxyCompactList}\item 
\hyperlink{classkdb_1_1Key}{Key} \hyperlink{classkdb_1_1KeySet_ad2b65a3aedad1e495351c770b29cd5c4}{head} () const 
\begin{DoxyCompactList}\small\item\em \end{DoxyCompactList}\item 
\hyperlink{classkdb_1_1Key}{Key} \hyperlink{classkdb_1_1KeySet_ac6ccd44a29326a0d9a5c2e60d3089b5e}{tail} () const 
\begin{DoxyCompactList}\small\item\em \end{DoxyCompactList}\item 
void \hyperlink{classkdb_1_1KeySet_a4476a586a48a64160c71ed480c681b19}{rewind} () const 
\begin{DoxyCompactList}\small\item\em \end{DoxyCompactList}\item 
\hyperlink{classkdb_1_1Key}{Key} \hyperlink{classkdb_1_1KeySet_a03f115c65cf2720411bb76d5f4e10c25}{next} () const 
\begin{DoxyCompactList}\small\item\em \end{DoxyCompactList}\item 
\hyperlink{classkdb_1_1Key}{Key} \hyperlink{classkdb_1_1KeySet_a2c9c26dbbf5ec0ed82093e1793a79fe1}{current} () const 
\begin{DoxyCompactList}\small\item\em \end{DoxyCompactList}\item 
void \hyperlink{classkdb_1_1KeySet_a844be268914882e5159424e9ee302119}{set\-Cursor} (cursor\-\_\-t cursor) const 
\begin{DoxyCompactList}\small\item\em \end{DoxyCompactList}\item 
cursor\-\_\-t \hyperlink{classkdb_1_1KeySet_ab3b63a96df7100e58cbb812e3d4223f2}{get\-Cursor} () const 
\begin{DoxyCompactList}\small\item\em \end{DoxyCompactList}\item 
\hyperlink{classkdb_1_1Key}{Key} \hyperlink{classkdb_1_1KeySet_a7f207457a1c12633a1a5301a3a1bbaed}{pop} ()
\begin{DoxyCompactList}\small\item\em \end{DoxyCompactList}\item 
\hyperlink{classkdb_1_1KeySet}{Key\-Set} \hyperlink{classkdb_1_1KeySet_ab283da798a7670d5c3f0e1a5b821e666}{cut} (\hyperlink{classkdb_1_1Key}{Key} k)
\begin{DoxyCompactList}\small\item\em \end{DoxyCompactList}\item 
\hyperlink{classkdb_1_1Key}{Key} \hyperlink{classkdb_1_1KeySet_a816e7468abe296f8352e090738c215cc}{lookup} (const \hyperlink{classkdb_1_1Key}{Key} \&k, const \hyperlink{group__kdb_ga98a3d6a4016c9dad9cbd1a99a9c2a45a}{option\-\_\-t} options=\hyperlink{group__kdb_gga98a3d6a4016c9dad9cbd1a99a9c2a45aa00738455e0ae843c8720809d8287f370}{K\-D\-B\-\_\-\-O\-\_\-\-N\-O\-N\-E}) const 
\begin{DoxyCompactList}\small\item\em \end{DoxyCompactList}\item 
\hyperlink{classkdb_1_1Key}{Key} \hyperlink{classkdb_1_1KeySet_a2bb4b6f5c46eb54c4f495832672e1e98}{lookup} (std\-::string const \&name, const \hyperlink{group__kdb_ga98a3d6a4016c9dad9cbd1a99a9c2a45a}{option\-\_\-t} options=\hyperlink{group__kdb_gga98a3d6a4016c9dad9cbd1a99a9c2a45aa00738455e0ae843c8720809d8287f370}{K\-D\-B\-\_\-\-O\-\_\-\-N\-O\-N\-E}) const 
\begin{DoxyCompactList}\small\item\em Lookup a key by name. \end{DoxyCompactList}\item 
\hyperlink{classkdb_1_1Key}{Key} \hyperlink{classkdb_1_1KeySet_ad4aa72767cf702066e804ef054fc7e5b}{at} (cursor\-\_\-t pos) const 
\begin{DoxyCompactList}\small\item\em Lookup a key by index. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
A keyset holds together a set of keys. 

Methods to manipulate Key\-Sets.  A Key\-Set is a sorted set of keys. So the correct name actually would be Key\-Map.

With \hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ks\-New()} you can create a new Key\-Set.

You can add keys with \hyperlink{group__keyset_gaa5a1d467a4d71041edce68ea7748ce45}{ks\-Append\-Key()} in the keyset. Using \hyperlink{group__keyset_ga21eb9c3a14a604ee3a8bdc779232e7b7}{ks\-Append()} you can append a whole keyset.

\begin{DoxyNote}{Note}
Because the key is not copied, also the pointer to the current metadata \hyperlink{group__keymeta_ga4c88342f580a4291455a801af71ce048}{key\-Next\-Meta()} will be shared. 
\end{DoxyNote}


\hyperlink{group__keyset_ga7474ad6b0a0fa969dbdf267ba5770eee}{ks\-Get\-Size()} tells you the current size of the keyset.

With \hyperlink{group__keyset_gabe793ff51f1728e3429c84a8a9086b70}{ks\-Rewind()} and \hyperlink{group__keyset_ga317321c9065b5a4b3e33fe1c399bcec9}{ks\-Next()} you can navigate through the keyset. Don't expect any particular order, but it is assured that you will get every key of the set.

Key\-Sets have an \hyperlink{group__keyset_ga4287b9416912c5f2ab9c195cb74fb094}{internal cursor }. This is used for \hyperlink{group__keyset_gaa34fc43a081e6b01e4120daa6c112004}{ks\-Lookup()} and \hyperlink{group__kdb_ga11436b058408f83d303ca5e996832bcf}{kdb\-Set()}.

Key\-Set has a fundamental meaning inside elektra. It makes it possible to get and store many keys at once inside the database. In addition to that the class can be used as high level datastructure in applications. With \hyperlink{group__keyset_gad2e30fb6d4739d917c5abb2ac2f9c1a1}{ks\-Lookup\-By\-Name()} it is possible to fetch easily specific keys out of the list of keys.

You can easily create and iterate keys\-: 
\begin{DoxyCode}
\textcolor{preprocessor}{#include <kdb.h>}

\textcolor{comment}{// create a new keyset with 3 keys}
\textcolor{comment}{// with a hint that about 20 keys will be inside}
KeySet *myConfig = \hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew}(20,
        \hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew} (\textcolor{stringliteral}{"user/name1"}, 0),
        \hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew} (\textcolor{stringliteral}{"user/name2"}, 0),
        \hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew} (\textcolor{stringliteral}{"user/name3"}, 0),
        KS\_END);
\textcolor{comment}{// append a key in the keyset}
\hyperlink{group__keyset_gaa5a1d467a4d71041edce68ea7748ce45}{ksAppendKey}(myConfig, \hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}(\textcolor{stringliteral}{"user/name4"}, 0));

Key *current;
\hyperlink{group__keyset_gabe793ff51f1728e3429c84a8a9086b70}{ksRewind}(myConfig);
\textcolor{keywordflow}{while} ((current=\hyperlink{group__keyset_ga317321c9065b5a4b3e33fe1c399bcec9}{ksNext}(myConfig))!=0)
\{
        printf(\textcolor{stringliteral}{"Key name is %s.\(\backslash\)n"}, \hyperlink{group__keyname_ga8e805c726a60da921d3736cda7813513}{keyName} (current));
\}
\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel} (myConfig); \textcolor{comment}{// delete keyset and all keys appended}
\end{DoxyCode}
 

\begin{DoxyInvariant}{Invariant}
always holds an underlying elektra keyset.
\end{DoxyInvariant}
\begin{DoxyNote}{Note}
that the cursor is mutable, so it might be changed even in const functions as described. 
\end{DoxyNote}


\subsection{Constructor \& Destructor Documentation}
\hypertarget{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{\index{kdb\-::\-Key\-Set@{kdb\-::\-Key\-Set}!Key\-Set@{Key\-Set}}
\index{Key\-Set@{Key\-Set}!kdb::KeySet@{kdb\-::\-Key\-Set}}
\subsubsection[{Key\-Set}]{\setlength{\rightskip}{0pt plus 5cm}kdb\-::\-Key\-Set\-::\-Key\-Set (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}




Creates a new empty keyset with no keys

Allocate, initialize and return a new \hyperlink{classkdb_1_1KeySet}{Key\-Set} object.

Objects created with \hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ks\-New()} must be destroyed with \hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ks\-Del()}.

You can use a various long list of parameters to preload the keyset with a list of keys. Either your first and only parameter is 0 or your last parameter must be K\-E\-Y\-\_\-\-E\-N\-D.

So, terminate with ks\-New(0) or ks\-New(20, ..., K\-S\-\_\-\-E\-N\-D)

For most uses 
\begin{DoxyCode}
\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet} *keys = \hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew}(0);
\textcolor{comment}{// work with it}
\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel} (keys);
\end{DoxyCode}
 goes ok, the alloc size will be 16, defined in kdbprivate.\-h. The alloc size will be doubled whenever size reaches alloc size, so it also performs out large keysets.

But if you have any clue how large your keyset may be you should read the next statements.

If you want a keyset with length 15 (because you know of your application that you normally need about 12 up to 15 keys), use\-: 
\begin{DoxyCode}
\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet} * keys = \hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew} (15,
        \hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew} (\textcolor{stringliteral}{"user/sw/app/fixedConfiguration/key01"}, KEY\_SWITCH\_VALUE,
       \textcolor{stringliteral}{"value01"}, 0),
        \hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew} (\textcolor{stringliteral}{"user/sw/app/fixedConfiguration/key02"}, KEY\_SWITCH\_VALUE,
       \textcolor{stringliteral}{"value02"}, 0),
        \hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew} (\textcolor{stringliteral}{"user/sw/app/fixedConfiguration/key03"}, KEY\_SWITCH\_VALUE,
       \textcolor{stringliteral}{"value03"}, 0),
        \textcolor{comment}{// ...}
        \hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew} (\textcolor{stringliteral}{"user/sw/app/fixedConfiguration/key15"}, KEY\_SWITCH\_VALUE,
       \textcolor{stringliteral}{"value15"}, 0),
        KS\_END);
\textcolor{comment}{// work with it}
\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel} (keys);
\end{DoxyCode}


If you start having 3 keys, and your application needs approximately 200-\/500 keys, you can use\-: 
\begin{DoxyCode}
\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet} * config = \hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew} (500,
        \hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew} (\textcolor{stringliteral}{"user/sw/app/fixedConfiguration/key1"}, KEY\_SWITCH\_VALUE, \textcolor{stringliteral}{
      "value1"}, 0),
        \hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew} (\textcolor{stringliteral}{"user/sw/app/fixedConfiguration/key2"}, KEY\_SWITCH\_VALUE, \textcolor{stringliteral}{
      "value2"}, 0),
        \hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew} (\textcolor{stringliteral}{"user/sw/app/fixedConfiguration/key3"}, KEY\_SWITCH\_VALUE, \textcolor{stringliteral}{
      "value3"}, 0),
        KS\_END); \textcolor{comment}{// don't forget the KS\_END at the end!}
\textcolor{comment}{// work with it}
\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel} (config);
\end{DoxyCode}
 Alloc size is 500, the size of the keyset will be 3 after ks\-New. This means the keyset will reallocate when appending more than 497 keys.

The main benefit of taking a list of variant length parameters is to be able to have one C-\/\-Statement for any possible \hyperlink{classkdb_1_1KeySet}{Key\-Set}.

Due to A\-B\-I compatibility, the {\ttfamily \hyperlink{classkdb_1_1KeySet}{Key\-Set}} structure is only declared in kdb.\-h, and not defined. So you can only declare {\ttfamily pointers} to {\ttfamily Key\-Sets} in your program. See \href{http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html#AEN135}{\tt http\-://tldp.\-org/\-H\-O\-W\-T\-O/\-Program-\/\-Library-\/\-H\-O\-W\-T\-O/shared-\/libraries.\-html\#\-A\-E\-N135}

\begin{DoxySeeAlso}{See Also}
\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ks\-Del()} to free the \hyperlink{group__keyset}{Key\-Set} afterwards 

\hyperlink{group__keyset_gac59e4b328245463f1451f68d5106151c}{ks\-Dup()} to duplicate an existing \hyperlink{group__keyset}{Key\-Set} 
\end{DoxySeeAlso}

\begin{DoxyParams}{Parameters}
{\em alloc} & gives a hint for the size how many Keys may be stored initially \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a ready to use \hyperlink{classkdb_1_1KeySet}{Key\-Set} object 

0 on memory error 
\end{DoxyReturn}
 \hypertarget{classkdb_1_1KeySet_a21f651ff310178951402038e590743e0}{\index{kdb\-::\-Key\-Set@{kdb\-::\-Key\-Set}!Key\-Set@{Key\-Set}}
\index{Key\-Set@{Key\-Set}!kdb::KeySet@{kdb\-::\-Key\-Set}}
\subsubsection[{Key\-Set}]{\setlength{\rightskip}{0pt plus 5cm}kdb\-::\-Key\-Set\-::\-Key\-Set (
\begin{DoxyParamCaption}
\item[{ckdb\-::\-Key\-Set $\ast$}]{k}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KeySet_a21f651ff310178951402038e590743e0}
Takes ownership of keyset!

Keyset will be destroyed at destructor you cant continue to use keyset afterwards!

Use \hyperlink{classkdb_1_1KeySet_a2987b3fb1b12196399650726f1c18f02}{Key\-Set\-::release()} to avoid destruction.


\begin{DoxyParams}{Parameters}
{\em k} & the keyset to take the ownership from \\
\hline
\end{DoxyParams}
\begin{DoxySeeAlso}{See Also}
\hyperlink{classkdb_1_1KeySet_a2987b3fb1b12196399650726f1c18f02}{release()} 

\hyperlink{classkdb_1_1KeySet_a9f3ec4eebe304185527b08a6fa01b77c}{set\-Key\-Set()} 
\end{DoxySeeAlso}
\hypertarget{classkdb_1_1KeySet_ad8d6df839ab852fded1739ff3398d0b1}{\index{kdb\-::\-Key\-Set@{kdb\-::\-Key\-Set}!Key\-Set@{Key\-Set}}
\index{Key\-Set@{Key\-Set}!kdb::KeySet@{kdb\-::\-Key\-Set}}
\subsubsection[{Key\-Set}]{\setlength{\rightskip}{0pt plus 5cm}kdb\-::\-Key\-Set\-::\-Key\-Set (
\begin{DoxyParamCaption}
\item[{const {\bf Key\-Set} \&}]{other}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KeySet_ad8d6df839ab852fded1739ff3398d0b1}
Duplicate a keyset.

This keyset will be a duplicate of the other afterwards.

\begin{DoxyNote}{Note}
that they still reference to the same Keys, so if you change key values also the keys in the original keyset will be changed.
\end{DoxyNote}
\begin{DoxySeeAlso}{See Also}
\hyperlink{classkdb_1_1KeySet_a72d0b50194fb1900c468b53e749369a2}{dup} 
\end{DoxySeeAlso}
\hypertarget{classkdb_1_1KeySet_abd9c4225de42a465621e7e9f6bd06d70}{\index{kdb\-::\-Key\-Set@{kdb\-::\-Key\-Set}!Key\-Set@{Key\-Set}}
\index{Key\-Set@{Key\-Set}!kdb::KeySet@{kdb\-::\-Key\-Set}}
\subsubsection[{Key\-Set}]{\setlength{\rightskip}{0pt plus 5cm}kdb\-::\-Key\-Set\-::\-Key\-Set (
\begin{DoxyParamCaption}
\item[{size\-\_\-t}]{alloc, }
\item[{va\-\_\-list}]{ap}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [explicit]}}}\label{classkdb_1_1KeySet_abd9c4225de42a465621e7e9f6bd06d70}


Create a new keyset. 


\begin{DoxyParams}{Parameters}
{\em alloc} & minimum number of keys to allocate \\
\hline
{\em ap} & variable arguments list\\
\hline
\end{DoxyParams}
Allocate, initialize and return a new \hyperlink{classkdb_1_1KeySet}{Key\-Set} object.

Objects created with \hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ks\-New()} must be destroyed with \hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ks\-Del()}.

You can use a various long list of parameters to preload the keyset with a list of keys. Either your first and only parameter is 0 or your last parameter must be K\-E\-Y\-\_\-\-E\-N\-D.

So, terminate with ks\-New(0) or ks\-New(20, ..., K\-S\-\_\-\-E\-N\-D)

For most uses 
\begin{DoxyCode}
\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet} *keys = \hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew}(0);
\textcolor{comment}{// work with it}
\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel} (keys);
\end{DoxyCode}
 goes ok, the alloc size will be 16, defined in kdbprivate.\-h. The alloc size will be doubled whenever size reaches alloc size, so it also performs out large keysets.

But if you have any clue how large your keyset may be you should read the next statements.

If you want a keyset with length 15 (because you know of your application that you normally need about 12 up to 15 keys), use\-: 
\begin{DoxyCode}
\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet} * keys = \hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew} (15,
        \hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew} (\textcolor{stringliteral}{"user/sw/app/fixedConfiguration/key01"}, KEY\_SWITCH\_VALUE,
       \textcolor{stringliteral}{"value01"}, 0),
        \hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew} (\textcolor{stringliteral}{"user/sw/app/fixedConfiguration/key02"}, KEY\_SWITCH\_VALUE,
       \textcolor{stringliteral}{"value02"}, 0),
        \hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew} (\textcolor{stringliteral}{"user/sw/app/fixedConfiguration/key03"}, KEY\_SWITCH\_VALUE,
       \textcolor{stringliteral}{"value03"}, 0),
        \textcolor{comment}{// ...}
        \hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew} (\textcolor{stringliteral}{"user/sw/app/fixedConfiguration/key15"}, KEY\_SWITCH\_VALUE,
       \textcolor{stringliteral}{"value15"}, 0),
        KS\_END);
\textcolor{comment}{// work with it}
\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel} (keys);
\end{DoxyCode}


If you start having 3 keys, and your application needs approximately 200-\/500 keys, you can use\-: 
\begin{DoxyCode}
\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet} * config = \hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew} (500,
        \hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew} (\textcolor{stringliteral}{"user/sw/app/fixedConfiguration/key1"}, KEY\_SWITCH\_VALUE, \textcolor{stringliteral}{
      "value1"}, 0),
        \hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew} (\textcolor{stringliteral}{"user/sw/app/fixedConfiguration/key2"}, KEY\_SWITCH\_VALUE, \textcolor{stringliteral}{
      "value2"}, 0),
        \hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew} (\textcolor{stringliteral}{"user/sw/app/fixedConfiguration/key3"}, KEY\_SWITCH\_VALUE, \textcolor{stringliteral}{
      "value3"}, 0),
        KS\_END); \textcolor{comment}{// don't forget the KS\_END at the end!}
\textcolor{comment}{// work with it}
\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel} (config);
\end{DoxyCode}
 Alloc size is 500, the size of the keyset will be 3 after ks\-New. This means the keyset will reallocate when appending more than 497 keys.

The main benefit of taking a list of variant length parameters is to be able to have one C-\/\-Statement for any possible \hyperlink{classkdb_1_1KeySet}{Key\-Set}.

Due to A\-B\-I compatibility, the {\ttfamily \hyperlink{classkdb_1_1KeySet}{Key\-Set}} structure is only declared in kdb.\-h, and not defined. So you can only declare {\ttfamily pointers} to {\ttfamily Key\-Sets} in your program. See \href{http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html#AEN135}{\tt http\-://tldp.\-org/\-H\-O\-W\-T\-O/\-Program-\/\-Library-\/\-H\-O\-W\-T\-O/shared-\/libraries.\-html\#\-A\-E\-N135}

\begin{DoxySeeAlso}{See Also}
\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ks\-Del()} to free the \hyperlink{group__keyset}{Key\-Set} afterwards 

\hyperlink{group__keyset_gac59e4b328245463f1451f68d5106151c}{ks\-Dup()} to duplicate an existing \hyperlink{group__keyset}{Key\-Set} 
\end{DoxySeeAlso}

\begin{DoxyParams}{Parameters}
{\em alloc} & gives a hint for the size how many Keys may be stored initially \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a ready to use \hyperlink{classkdb_1_1KeySet}{Key\-Set} object 

0 on memory error 
\end{DoxyReturn}


\begin{DoxyPrecond}{Precondition}
caller must call va\-\_\-start and va\-\_\-end 
\end{DoxyPrecond}
\begin{DoxyParagraph}{va the list of arguments}

\end{DoxyParagraph}
 \hypertarget{classkdb_1_1KeySet_ab4bb5ec4e73eca8ea1bd0a843a6489d4}{\index{kdb\-::\-Key\-Set@{kdb\-::\-Key\-Set}!Key\-Set@{Key\-Set}}
\index{Key\-Set@{Key\-Set}!kdb::KeySet@{kdb\-::\-Key\-Set}}
\subsubsection[{Key\-Set}]{\setlength{\rightskip}{0pt plus 5cm}kdb\-::\-Key\-Set\-::\-Key\-Set (
\begin{DoxyParamCaption}
\item[{size\-\_\-t}]{alloc, }
\item[{}]{...}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [explicit]}}}\label{classkdb_1_1KeySet_ab4bb5ec4e73eca8ea1bd0a843a6489d4}


Create a new keyset. 


\begin{DoxyParams}{Parameters}
{\em alloc} & minimum number of keys to allocate \\
\hline
{\em ...} & variable argument list\\
\hline
\end{DoxyParams}
Allocate, initialize and return a new \hyperlink{classkdb_1_1KeySet}{Key\-Set} object.

Objects created with \hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ks\-New()} must be destroyed with \hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ks\-Del()}.

You can use a various long list of parameters to preload the keyset with a list of keys. Either your first and only parameter is 0 or your last parameter must be K\-E\-Y\-\_\-\-E\-N\-D.

So, terminate with ks\-New(0) or ks\-New(20, ..., K\-S\-\_\-\-E\-N\-D)

For most uses 
\begin{DoxyCode}
\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet} *keys = \hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew}(0);
\textcolor{comment}{// work with it}
\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel} (keys);
\end{DoxyCode}
 goes ok, the alloc size will be 16, defined in kdbprivate.\-h. The alloc size will be doubled whenever size reaches alloc size, so it also performs out large keysets.

But if you have any clue how large your keyset may be you should read the next statements.

If you want a keyset with length 15 (because you know of your application that you normally need about 12 up to 15 keys), use\-: 
\begin{DoxyCode}
\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet} * keys = \hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew} (15,
        \hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew} (\textcolor{stringliteral}{"user/sw/app/fixedConfiguration/key01"}, KEY\_SWITCH\_VALUE,
       \textcolor{stringliteral}{"value01"}, 0),
        \hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew} (\textcolor{stringliteral}{"user/sw/app/fixedConfiguration/key02"}, KEY\_SWITCH\_VALUE,
       \textcolor{stringliteral}{"value02"}, 0),
        \hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew} (\textcolor{stringliteral}{"user/sw/app/fixedConfiguration/key03"}, KEY\_SWITCH\_VALUE,
       \textcolor{stringliteral}{"value03"}, 0),
        \textcolor{comment}{// ...}
        \hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew} (\textcolor{stringliteral}{"user/sw/app/fixedConfiguration/key15"}, KEY\_SWITCH\_VALUE,
       \textcolor{stringliteral}{"value15"}, 0),
        KS\_END);
\textcolor{comment}{// work with it}
\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel} (keys);
\end{DoxyCode}


If you start having 3 keys, and your application needs approximately 200-\/500 keys, you can use\-: 
\begin{DoxyCode}
\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet} * config = \hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew} (500,
        \hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew} (\textcolor{stringliteral}{"user/sw/app/fixedConfiguration/key1"}, KEY\_SWITCH\_VALUE, \textcolor{stringliteral}{
      "value1"}, 0),
        \hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew} (\textcolor{stringliteral}{"user/sw/app/fixedConfiguration/key2"}, KEY\_SWITCH\_VALUE, \textcolor{stringliteral}{
      "value2"}, 0),
        \hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew} (\textcolor{stringliteral}{"user/sw/app/fixedConfiguration/key3"}, KEY\_SWITCH\_VALUE, \textcolor{stringliteral}{
      "value3"}, 0),
        KS\_END); \textcolor{comment}{// don't forget the KS\_END at the end!}
\textcolor{comment}{// work with it}
\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel} (config);
\end{DoxyCode}
 Alloc size is 500, the size of the keyset will be 3 after ks\-New. This means the keyset will reallocate when appending more than 497 keys.

The main benefit of taking a list of variant length parameters is to be able to have one C-\/\-Statement for any possible \hyperlink{classkdb_1_1KeySet}{Key\-Set}.

Due to A\-B\-I compatibility, the {\ttfamily \hyperlink{classkdb_1_1KeySet}{Key\-Set}} structure is only declared in kdb.\-h, and not defined. So you can only declare {\ttfamily pointers} to {\ttfamily Key\-Sets} in your program. See \href{http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html#AEN135}{\tt http\-://tldp.\-org/\-H\-O\-W\-T\-O/\-Program-\/\-Library-\/\-H\-O\-W\-T\-O/shared-\/libraries.\-html\#\-A\-E\-N135}

\begin{DoxySeeAlso}{See Also}
\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ks\-Del()} to free the \hyperlink{group__keyset}{Key\-Set} afterwards 

\hyperlink{group__keyset_gac59e4b328245463f1451f68d5106151c}{ks\-Dup()} to duplicate an existing \hyperlink{group__keyset}{Key\-Set} 
\end{DoxySeeAlso}

\begin{DoxyParams}{Parameters}
{\em alloc} & gives a hint for the size how many Keys may be stored initially \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a ready to use \hyperlink{classkdb_1_1KeySet}{Key\-Set} object 

0 on memory error 
\end{DoxyReturn}


\begin{DoxyPrecond}{Precondition}
caller must call va\-\_\-start and va\-\_\-end 
\end{DoxyPrecond}
\begin{DoxyParagraph}{va the list of arguments}

\end{DoxyParagraph}
 \hypertarget{classkdb_1_1KeySet_ade654f92bddec24abad1b651e828f2b8}{\index{kdb\-::\-Key\-Set@{kdb\-::\-Key\-Set}!$\sim$\-Key\-Set@{$\sim$\-Key\-Set}}
\index{$\sim$\-Key\-Set@{$\sim$\-Key\-Set}!kdb::KeySet@{kdb\-::\-Key\-Set}}
\subsubsection[{$\sim$\-Key\-Set}]{\setlength{\rightskip}{0pt plus 5cm}kdb\-::\-Key\-Set\-::$\sim$\-Key\-Set (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KeySet_ade654f92bddec24abad1b651e828f2b8}


Deconstruct a keyset. 

A destructor for \hyperlink{classkdb_1_1KeySet}{Key\-Set} objects.

Cleans all internal dynamic attributes, decrement all reference pointers to all keys and then \hyperlink{group__key_ga3df95bbc2494e3e6703ece5639be5bb1}{key\-Del()} all contained Keys, and free()s the release the \hyperlink{classkdb_1_1KeySet}{Key\-Set} object memory (that was previously allocated by \hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ks\-New()}).


\begin{DoxyParams}{Parameters}
{\em ks} & the keyset object to work with \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 when the keyset was freed 

-\/1 on null pointer 
\end{DoxyReturn}
\begin{DoxySeeAlso}{See Also}
\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ks\-New()} 
\end{DoxySeeAlso}
 

\subsection{Member Function Documentation}
\hypertarget{classkdb_1_1KeySet_a0d4b2f3aa9f58d10053561135b50233e}{\index{kdb\-::\-Key\-Set@{kdb\-::\-Key\-Set}!append@{append}}
\index{append@{append}!kdb::KeySet@{kdb\-::\-Key\-Set}}
\subsubsection[{append}]{\setlength{\rightskip}{0pt plus 5cm}ssize\-\_\-t kdb\-::\-Key\-Set\-::append (
\begin{DoxyParamCaption}
\item[{const {\bf Key} \&}]{to\-Append}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KeySet_a0d4b2f3aa9f58d10053561135b50233e}


append a key 


\begin{DoxyParams}{Parameters}
{\em to\-Append} & key to append\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
number of keys in the keyset
\end{DoxyReturn}
Appends a \hyperlink{classkdb_1_1Key}{Key} to the end of {\ttfamily ks}.

A pointer to the key will be stored, and not a private copy. So a future \hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ks\-Del()} on {\ttfamily ks} may \hyperlink{group__key_ga3df95bbc2494e3e6703ece5639be5bb1}{key\-Del()} the {\ttfamily to\-Append} object, see \hyperlink{group__key_ga4aabc4272506dd63161db2bbb42de8ae}{key\-Get\-Ref()}.

The reference counter of the key will be incremented, and thus to\-Append is not const.

\begin{DoxyNote}{Note}
Because the key is not copied, also the pointer to the current metadata \hyperlink{group__keymeta_ga4c88342f580a4291455a801af71ce048}{key\-Next\-Meta()} will be shared. 
\end{DoxyNote}


If the keyname already existed, it will be replaced with the new key.

The \hyperlink{classkdb_1_1KeySet}{Key\-Set} internal cursor will be set to the new key.

It is save to use ks\-Append\-Key(ks, key\-New(..)).

\begin{DoxyReturn}{Returns}
the size of the \hyperlink{classkdb_1_1KeySet}{Key\-Set} after insertion 

-\/1 on N\-U\-L\-L pointers 

-\/1 if insertion failed, the key will be deleted then. 
\end{DoxyReturn}

\begin{DoxyParams}{Parameters}
{\em ks} & \hyperlink{classkdb_1_1KeySet}{Key\-Set} that will receive the key \\
\hline
{\em to\-Append} & \hyperlink{classkdb_1_1Key}{Key} that will be appended to ks or deleted \\
\hline
\end{DoxyParams}
\begin{DoxySeeAlso}{See Also}
\hyperlink{group__keyset_ga21eb9c3a14a604ee3a8bdc779232e7b7}{ks\-Append()}, \hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{key\-New()}, \hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ks\-Del()} 

\hyperlink{group__key_ga6970a6f254d67af7e39f8e469bb162f1}{key\-Inc\-Ref()} 
\end{DoxySeeAlso}
 \hypertarget{classkdb_1_1KeySet_ac9cbdc933d7171037d47c6d4d78595d1}{\index{kdb\-::\-Key\-Set@{kdb\-::\-Key\-Set}!append@{append}}
\index{append@{append}!kdb::KeySet@{kdb\-::\-Key\-Set}}
\subsubsection[{append}]{\setlength{\rightskip}{0pt plus 5cm}ssize\-\_\-t kdb\-::\-Key\-Set\-::append (
\begin{DoxyParamCaption}
\item[{const {\bf Key\-Set} \&}]{to\-Append}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KeySet_ac9cbdc933d7171037d47c6d4d78595d1}


append a keyset 


\begin{DoxyParams}{Parameters}
{\em to\-Append} & keyset to append\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
number of keys in the keyset
\end{DoxyReturn}
Append all {\ttfamily to\-Append} contained keys to the end of the {\ttfamily ks}.

{\ttfamily to\-Append} \hyperlink{classkdb_1_1KeySet}{Key\-Set} will be left unchanged.

If a key is both in to\-Append and ks, the \hyperlink{classkdb_1_1Key}{Key} in ks will be overridden.

\begin{DoxyNote}{Note}
Because the key is not copied, also the pointer to the current metadata \hyperlink{group__keymeta_ga4c88342f580a4291455a801af71ce048}{key\-Next\-Meta()} will be shared. 
\end{DoxyNote}


\begin{DoxyPostcond}{Postcondition}
Sorted \hyperlink{classkdb_1_1KeySet}{Key\-Set} ks with all keys it had before and additionally the keys from to\-Append 
\end{DoxyPostcond}
\begin{DoxyReturn}{Returns}
the size of the \hyperlink{classkdb_1_1KeySet}{Key\-Set} after transfer 

-\/1 on N\-U\-L\-L pointers 
\end{DoxyReturn}

\begin{DoxyParams}{Parameters}
{\em ks} & the \hyperlink{classkdb_1_1KeySet}{Key\-Set} that will receive the keys \\
\hline
{\em to\-Append} & the \hyperlink{classkdb_1_1KeySet}{Key\-Set} that provides the keys that will be transferred \\
\hline
\end{DoxyParams}
\begin{DoxySeeAlso}{See Also}
\hyperlink{group__keyset_gaa5a1d467a4d71041edce68ea7748ce45}{ks\-Append\-Key()} 
\end{DoxySeeAlso}
 \hypertarget{classkdb_1_1KeySet_ad4aa72767cf702066e804ef054fc7e5b}{\index{kdb\-::\-Key\-Set@{kdb\-::\-Key\-Set}!at@{at}}
\index{at@{at}!kdb::KeySet@{kdb\-::\-Key\-Set}}
\subsubsection[{at}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Key} kdb\-::\-Key\-Set\-::at (
\begin{DoxyParamCaption}
\item[{cursor\-\_\-t}]{pos}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KeySet_ad4aa72767cf702066e804ef054fc7e5b}


Lookup a key by index. 


\begin{DoxyParams}{Parameters}
{\em pos} & cursor position\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the found key 
\end{DoxyReturn}
\hypertarget{classkdb_1_1KeySet_a38f5159e39758aa632421d2fe7440633}{\index{kdb\-::\-Key\-Set@{kdb\-::\-Key\-Set}!clear@{clear}}
\index{clear@{clear}!kdb::KeySet@{kdb\-::\-Key\-Set}}
\subsubsection[{clear}]{\setlength{\rightskip}{0pt plus 5cm}void kdb\-::\-Key\-Set\-::clear (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KeySet_a38f5159e39758aa632421d2fe7440633}


Clear the keyset. 

Keyset will have no keys afterwards. \hypertarget{classkdb_1_1KeySet_a28fd33fdaecf1d57d4dddac7058f5d38}{\index{kdb\-::\-Key\-Set@{kdb\-::\-Key\-Set}!copy@{copy}}
\index{copy@{copy}!kdb::KeySet@{kdb\-::\-Key\-Set}}
\subsubsection[{copy}]{\setlength{\rightskip}{0pt plus 5cm}void kdb\-::\-Key\-Set\-::copy (
\begin{DoxyParamCaption}
\item[{const {\bf Key\-Set} \&}]{other}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KeySet_a28fd33fdaecf1d57d4dddac7058f5d38}


Copy a keyset. 


\begin{DoxyParams}{Parameters}
{\em other} & other keyset to copy\\
\hline
\end{DoxyParams}
Copy a keyset.

Most often you may want a duplicate of a keyset, see \hyperlink{group__keyset_gac59e4b328245463f1451f68d5106151c}{ks\-Dup()} or append keys, see \hyperlink{group__keyset_ga21eb9c3a14a604ee3a8bdc779232e7b7}{ks\-Append()}. But in some situations you need to copy a keyset to a existing keyset, for that this function exists.

You can also use it to clear a keyset when you pass a N\-U\-L\-L pointer as {\ttfamily source}.

Note that all keys in {\ttfamily dest} will be deleted. Afterwards the content of the source will be added to the destination and the \hyperlink{group__keyset_ga4287b9416912c5f2ab9c195cb74fb094}{ks\-Current()} is set properly in {\ttfamily dest}.

A flat copy is made, so the keys will not be duplicated, but there reference counter is updated, so both keysets need to be \hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ks\-Del()}.

\begin{DoxyNote}{Note}
Because the key is not copied, also the pointer to the current metadata \hyperlink{group__keymeta_ga4c88342f580a4291455a801af71ce048}{key\-Next\-Meta()} will be shared. 
\end{DoxyNote}



\begin{DoxyCode}
\textcolor{keywordtype}{int} f (\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet} *ks)
\{
        \hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet} *c = \hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew} (20, ..., KS\_END);
        \textcolor{comment}{// c receives keys}
        \hyperlink{group__keyset_gaba1f1dbea191f4d7e7eb3e4296ae7d5e}{ksCopy} (ks, c); \textcolor{comment}{// pass the keyset to the caller}

        \hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel} (c);
\}       \textcolor{comment}{// caller needs to ksDel (ks)}
\end{DoxyCode}



\begin{DoxyParams}{Parameters}
{\em source} & has to be an initialized source \hyperlink{classkdb_1_1KeySet}{Key\-Set} or N\-U\-L\-L \\
\hline
{\em dest} & has to be an initialized \hyperlink{classkdb_1_1KeySet}{Key\-Set} where to write the keys \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
1 on success 

0 if dest was cleared successfully (source is N\-U\-L\-L) 

-\/1 on N\-U\-L\-L pointer 
\end{DoxyReturn}
\begin{DoxySeeAlso}{See Also}
\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ks\-New()}, \hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ks\-Del()}, \hyperlink{group__keyset_gac59e4b328245463f1451f68d5106151c}{ks\-Dup()} 

\hyperlink{group__key_ga6a12cbbe656a1ad9f41b8c681d7a2f92}{key\-Copy()} for copying keys 
\end{DoxySeeAlso}
 \hypertarget{classkdb_1_1KeySet_a2c9c26dbbf5ec0ed82093e1793a79fe1}{\index{kdb\-::\-Key\-Set@{kdb\-::\-Key\-Set}!current@{current}}
\index{current@{current}!kdb::KeySet@{kdb\-::\-Key\-Set}}
\subsubsection[{current}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Key} kdb\-::\-Key\-Set\-::current (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KeySet_a2c9c26dbbf5ec0ed82093e1793a79fe1}




Return the current \hyperlink{classkdb_1_1Key}{Key}.

The pointer is N\-U\-L\-L if you reached the end or after \hyperlink{group__keyset_gabe793ff51f1728e3429c84a8a9086b70}{ks\-Rewind()}.

\begin{DoxyNote}{Note}
You must not delete the key or change the key, use \hyperlink{group__keyset_gae42530b04defb772059de0600159cf69}{ks\-Pop()} if you want to delete it.
\end{DoxyNote}

\begin{DoxyParams}{Parameters}
{\em ks} & the keyset object to work with \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
pointer to the \hyperlink{classkdb_1_1Key}{Key} pointed by {\ttfamily ks's} cursor 

0 on N\-U\-L\-L pointer 
\end{DoxyReturn}
\begin{DoxySeeAlso}{See Also}
\hyperlink{group__keyset_ga317321c9065b5a4b3e33fe1c399bcec9}{ks\-Next()}, \hyperlink{group__keyset_gabe793ff51f1728e3429c84a8a9086b70}{ks\-Rewind()} 
\end{DoxySeeAlso}
 \hypertarget{classkdb_1_1KeySet_ab283da798a7670d5c3f0e1a5b821e666}{\index{kdb\-::\-Key\-Set@{kdb\-::\-Key\-Set}!cut@{cut}}
\index{cut@{cut}!kdb::KeySet@{kdb\-::\-Key\-Set}}
\subsubsection[{cut}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Key\-Set} kdb\-::\-Key\-Set\-::cut (
\begin{DoxyParamCaption}
\item[{{\bf Key}}]{k}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KeySet_ab283da798a7670d5c3f0e1a5b821e666}




Cuts out a keyset at the cutpoint.

Searches for the cutpoint inside the \hyperlink{classkdb_1_1KeySet}{Key\-Set} ks. If found it cuts out everything which is below (see \hyperlink{group__keytest_ga03332b5d97c76a4fd2640aca4762b8df}{key\-Is\-Below()}) this key. If not found an empty keyset is returned.

The cursor will stay at the same key as it was before. If the cursor was inside the region of cutted (moved) keys, the cursor will be set to the key before the cutpoint.

\begin{DoxyReturn}{Returns}
a new allocated \hyperlink{classkdb_1_1KeySet}{Key\-Set} which needs to deleted with \hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ks\-Del()}. The keyset consists of all keys (of the original keyset ks) below the cutpoint. If the key cutpoint exists, it will also be appended. 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em 0} & on null pointers, no key name or allocation problems \\
\hline
\end{DoxyRetVals}

\begin{DoxyParams}{Parameters}
{\em ks} & the keyset to cut. It will be modified by removing all keys below the cutpoint. The cutpoint itself will also be removed. \\
\hline
{\em cutpoint} & the point where to cut out the keyset \\
\hline
\end{DoxyParams}
 \hypertarget{classkdb_1_1KeySet_a72d0b50194fb1900c468b53e749369a2}{\index{kdb\-::\-Key\-Set@{kdb\-::\-Key\-Set}!dup@{dup}}
\index{dup@{dup}!kdb::KeySet@{kdb\-::\-Key\-Set}}
\subsubsection[{dup}]{\setlength{\rightskip}{0pt plus 5cm}ckdb\-::\-Key\-Set $\ast$ kdb\-::\-Key\-Set\-::dup (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KeySet_a72d0b50194fb1900c468b53e749369a2}


Duplicate a keyset. 

\begin{DoxyReturn}{Returns}
a copy of the keys
\end{DoxyReturn}
Return a duplicate of a keyset.

Objects created with \hyperlink{group__keyset_gac59e4b328245463f1451f68d5106151c}{ks\-Dup()} must be destroyed with \hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ks\-Del()}.

Memory will be allocated as needed for dynamic properties, so you need to \hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ks\-Del()} the returned pointer.

A flat copy is made, so the keys will not be duplicated, but there reference counter is updated, so both keysets need \hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ks\-Del()}.


\begin{DoxyParams}{Parameters}
{\em source} & has to be an initializised source \hyperlink{classkdb_1_1KeySet}{Key\-Set} \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a flat copy of source on success 

0 on N\-U\-L\-L pointer 
\end{DoxyReturn}
\begin{DoxySeeAlso}{See Also}
\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ks\-New()}, \hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ks\-Del()} 

\hyperlink{group__key_gae6ec6a60cc4b8c1463fa08623d056ce3}{key\-Dup()} for \hyperlink{group__key}{Key} duplication 
\end{DoxySeeAlso}
 \hypertarget{classkdb_1_1KeySet_ab3b63a96df7100e58cbb812e3d4223f2}{\index{kdb\-::\-Key\-Set@{kdb\-::\-Key\-Set}!get\-Cursor@{get\-Cursor}}
\index{get\-Cursor@{get\-Cursor}!kdb::KeySet@{kdb\-::\-Key\-Set}}
\subsubsection[{get\-Cursor}]{\setlength{\rightskip}{0pt plus 5cm}cursor\-\_\-t kdb\-::\-Key\-Set\-::get\-Cursor (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KeySet_ab3b63a96df7100e58cbb812e3d4223f2}




Get the \hyperlink{classkdb_1_1KeySet}{Key\-Set} internal cursor.

Use it to get the cursor of the actual position.

\begin{DoxyWarning}{Warning}
Cursors are getting invalid when the key was \hyperlink{group__keyset_gae42530b04defb772059de0600159cf69}{ks\-Pop()}ed or \hyperlink{group__keyset_gaa34fc43a081e6b01e4120daa6c112004}{ks\-Lookup()} with K\-D\-B\-\_\-\-O\-\_\-\-P\-O\-P was used.
\end{DoxyWarning}
 \hypertarget{classkdb_1_1KeySet_aa79bbbfb6e2f3e9c48cb3e595f9cda51}{\index{kdb\-::\-Key\-Set@{kdb\-::\-Key\-Set}!get\-Key\-Set@{get\-Key\-Set}}
\index{get\-Key\-Set@{get\-Key\-Set}!kdb::KeySet@{kdb\-::\-Key\-Set}}
\subsubsection[{get\-Key\-Set}]{\setlength{\rightskip}{0pt plus 5cm}ckdb\-::\-Key\-Set $\ast$ kdb\-::\-Key\-Set\-::get\-Key\-Set (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KeySet_aa79bbbfb6e2f3e9c48cb3e595f9cda51}


Passes out the raw keyset pointer. 

\begin{DoxyReturn}{Returns}
pointer to internal ckdb \hyperlink{classkdb_1_1KeySet}{Key\-Set}
\end{DoxyReturn}
\begin{DoxySeeAlso}{See Also}
\hyperlink{classkdb_1_1KeySet_a2987b3fb1b12196399650726f1c18f02}{release()} 

\hyperlink{classkdb_1_1KeySet_a9f3ec4eebe304185527b08a6fa01b77c}{set\-Key\-Set()} 
\end{DoxySeeAlso}
\hypertarget{classkdb_1_1KeySet_ad2b65a3aedad1e495351c770b29cd5c4}{\index{kdb\-::\-Key\-Set@{kdb\-::\-Key\-Set}!head@{head}}
\index{head@{head}!kdb::KeySet@{kdb\-::\-Key\-Set}}
\subsubsection[{head}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Key} kdb\-::\-Key\-Set\-::head (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KeySet_ad2b65a3aedad1e495351c770b29cd5c4}




\begin{DoxyReturn}{Returns}
alphabetical first key
\end{DoxyReturn}
Return the first key in the \hyperlink{classkdb_1_1KeySet}{Key\-Set}.

The Key\-Sets cursor will not be effected.

If \hyperlink{group__keyset_ga4287b9416912c5f2ab9c195cb74fb094}{ks\-Current()}==\hyperlink{group__keyset_gae7dbf3aef70e67b5328475eb3d1f92f5}{ks\-Head()} you know you are on the first key.


\begin{DoxyParams}{Parameters}
{\em ks} & the keyset object to work with \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the first \hyperlink{classkdb_1_1Key}{Key} of a keyset 

0 on N\-U\-L\-L pointer or empty keyset 
\end{DoxyReturn}
\begin{DoxySeeAlso}{See Also}
\hyperlink{group__keyset_gadca442c4ab43cf532b15091d7711559e}{ks\-Tail()} for the last \hyperlink{group__key}{Key} 

\hyperlink{group__keyset_gabe793ff51f1728e3429c84a8a9086b70}{ks\-Rewind()}, \hyperlink{group__keyset_ga4287b9416912c5f2ab9c195cb74fb094}{ks\-Current()} and \hyperlink{group__keyset_ga317321c9065b5a4b3e33fe1c399bcec9}{ks\-Next()} for iterating over the \hyperlink{group__keyset}{Key\-Set} 
\end{DoxySeeAlso}
 \hypertarget{classkdb_1_1KeySet_a816e7468abe296f8352e090738c215cc}{\index{kdb\-::\-Key\-Set@{kdb\-::\-Key\-Set}!lookup@{lookup}}
\index{lookup@{lookup}!kdb::KeySet@{kdb\-::\-Key\-Set}}
\subsubsection[{lookup}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Key} kdb\-::\-Key\-Set\-::lookup (
\begin{DoxyParamCaption}
\item[{const {\bf Key} \&}]{key, }
\item[{const {\bf option\-\_\-t}}]{options = {\ttfamily {\bf K\-D\-B\-\_\-\-O\-\_\-\-N\-O\-N\-E}}}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KeySet_a816e7468abe296f8352e090738c215cc}




Look for a \hyperlink{classkdb_1_1Key}{Key} contained in {\ttfamily ks} that matches the name of the {\ttfamily key}.

\begin{DoxyNote}{Note}
That the internal key cursor will point to the found key 
\end{DoxyNote}
\hypertarget{classkdb_1_1KeySet_a2bb4b6f5c46eb54c4f495832672e1e98}{\index{kdb\-::\-Key\-Set@{kdb\-::\-Key\-Set}!lookup@{lookup}}
\index{lookup@{lookup}!kdb::KeySet@{kdb\-::\-Key\-Set}}
\subsubsection[{lookup}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Key} kdb\-::\-Key\-Set\-::lookup (
\begin{DoxyParamCaption}
\item[{std\-::string const \&}]{name, }
\item[{const {\bf option\-\_\-t}}]{options = {\ttfamily {\bf K\-D\-B\-\_\-\-O\-\_\-\-N\-O\-N\-E}}}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KeySet_a2bb4b6f5c46eb54c4f495832672e1e98}


Lookup a key by name. 


\begin{DoxyParams}{Parameters}
{\em name} & the name to look for \\
\hline
{\em options} & some options to pass\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the found key 
\end{DoxyReturn}
\begin{DoxySeeAlso}{See Also}
\hyperlink{classkdb_1_1KeySet_a816e7468abe296f8352e090738c215cc}{lookup} (const \hyperlink{classkdb_1_1Key}{Key} \&\hyperlink{group__key}{Key}, const \hyperlink{group__kdb_ga98a3d6a4016c9dad9cbd1a99a9c2a45a}{option\-\_\-t} options)
\end{DoxySeeAlso}
\begin{DoxyNote}{Note}
That the internal key cursor will point to the found key 
\end{DoxyNote}
\hypertarget{classkdb_1_1KeySet_a03f115c65cf2720411bb76d5f4e10c25}{\index{kdb\-::\-Key\-Set@{kdb\-::\-Key\-Set}!next@{next}}
\index{next@{next}!kdb::KeySet@{kdb\-::\-Key\-Set}}
\subsubsection[{next}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Key} kdb\-::\-Key\-Set\-::next (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KeySet_a03f115c65cf2720411bb76d5f4e10c25}




Returns the next \hyperlink{classkdb_1_1Key}{Key} in a \hyperlink{classkdb_1_1KeySet}{Key\-Set}.

Key\-Sets have an internal cursor that can be reset with \hyperlink{group__keyset_gabe793ff51f1728e3429c84a8a9086b70}{ks\-Rewind()}. Every time \hyperlink{group__keyset_ga317321c9065b5a4b3e33fe1c399bcec9}{ks\-Next()} is called the cursor is incremented and the new current \hyperlink{classkdb_1_1Key}{Key} is returned.

You'll get a N\-U\-L\-L pointer if the key after the end of the \hyperlink{classkdb_1_1KeySet}{Key\-Set} was reached. On subsequent calls of \hyperlink{group__keyset_ga317321c9065b5a4b3e33fe1c399bcec9}{ks\-Next()} it will still return the N\-U\-L\-L pointer.

The {\ttfamily ks} internal cursor will be changed, so it is not const.

\begin{DoxyNote}{Note}
You must not delete or change the key, use \hyperlink{group__keyset_gae42530b04defb772059de0600159cf69}{ks\-Pop()} if you want to delete it.
\end{DoxyNote}

\begin{DoxyParams}{Parameters}
{\em ks} & the keyset object to work with \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the new current \hyperlink{classkdb_1_1Key}{Key} 

0 when the end is reached 

0 on N\-U\-L\-L pointer 
\end{DoxyReturn}
\begin{DoxySeeAlso}{See Also}
\hyperlink{group__keyset_gabe793ff51f1728e3429c84a8a9086b70}{ks\-Rewind()}, \hyperlink{group__keyset_ga4287b9416912c5f2ab9c195cb74fb094}{ks\-Current()} 
\end{DoxySeeAlso}
 \hypertarget{classkdb_1_1KeySet_a1c54736b7206bc2253d02a5bf4b3ccfb}{\index{kdb\-::\-Key\-Set@{kdb\-::\-Key\-Set}!operator=@{operator=}}
\index{operator=@{operator=}!kdb::KeySet@{kdb\-::\-Key\-Set}}
\subsubsection[{operator=}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Key\-Set} \& kdb\-::\-Key\-Set\-::operator= (
\begin{DoxyParamCaption}
\item[{{\bf Key\-Set} const \&}]{other}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KeySet_a1c54736b7206bc2253d02a5bf4b3ccfb}
Duplicate a keyset.

This keyset will be a duplicate of the other afterwards.

\begin{DoxyNote}{Note}
that they still reference to the same Keys, so if you change key values also the keys in the original keyset will be changed. 
\end{DoxyNote}
\hypertarget{classkdb_1_1KeySet_a7f207457a1c12633a1a5301a3a1bbaed}{\index{kdb\-::\-Key\-Set@{kdb\-::\-Key\-Set}!pop@{pop}}
\index{pop@{pop}!kdb::KeySet@{kdb\-::\-Key\-Set}}
\subsubsection[{pop}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Key} kdb\-::\-Key\-Set\-::pop (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KeySet_a7f207457a1c12633a1a5301a3a1bbaed}




Remove and return the last key of {\ttfamily ks}.

The reference counter will be decremented by one.

The Key\-Sets cursor will not be effected if it did not point to the popped key.

\begin{DoxyNote}{Note}
You need to \hyperlink{group__key_ga3df95bbc2494e3e6703ece5639be5bb1}{key\-Del()} the key afterwards, if you don't append it to another keyset. It has the same semantics like a key allocated with \hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{key\-New()} or \hyperlink{group__key_gae6ec6a60cc4b8c1463fa08623d056ce3}{key\-Dup()}.
\end{DoxyNote}

\begin{DoxyCode}
ks1=\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew}(0);
ks2=\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew}(0);

k1=\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}(\textcolor{stringliteral}{"user/name"}, \hyperlink{group__key_gga91fb3178848bd682000958089abbaf40aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}); \textcolor{comment}{// ref counter 0}
\hyperlink{group__keyset_gaa5a1d467a4d71041edce68ea7748ce45}{ksAppendKey}(ks1, k1); \textcolor{comment}{// ref counter 1}
\hyperlink{group__keyset_gaa5a1d467a4d71041edce68ea7748ce45}{ksAppendKey}(ks2, k1); \textcolor{comment}{// ref counter 2}

k1=\hyperlink{group__keyset_gae42530b04defb772059de0600159cf69}{ksPop} (ks1); \textcolor{comment}{// ref counter 1}
k1=\hyperlink{group__keyset_gae42530b04defb772059de0600159cf69}{ksPop} (ks2); \textcolor{comment}{// ref counter 0, like after keyNew()}

\hyperlink{group__keyset_gaa5a1d467a4d71041edce68ea7748ce45}{ksAppendKey}(ks1, k1); \textcolor{comment}{// ref counter 1}

\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel} (ks1); \textcolor{comment}{// key is deleted too}
\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel} (ks2);
 *
\end{DoxyCode}


\begin{DoxyReturn}{Returns}
the last key of {\ttfamily ks} 

N\-U\-L\-L if {\ttfamily ks} is empty or on N\-U\-L\-L pointer 
\end{DoxyReturn}

\begin{DoxyParams}{Parameters}
{\em ks} & \hyperlink{classkdb_1_1KeySet}{Key\-Set} to work with \\
\hline
\end{DoxyParams}
\begin{DoxySeeAlso}{See Also}
\hyperlink{group__keyset_gaa5a1d467a4d71041edce68ea7748ce45}{ks\-Append\-Key()}, \hyperlink{group__keyset_ga21eb9c3a14a604ee3a8bdc779232e7b7}{ks\-Append()} 

command\-List() for an example 
\end{DoxySeeAlso}
 \hypertarget{classkdb_1_1KeySet_a2987b3fb1b12196399650726f1c18f02}{\index{kdb\-::\-Key\-Set@{kdb\-::\-Key\-Set}!release@{release}}
\index{release@{release}!kdb::KeySet@{kdb\-::\-Key\-Set}}
\subsubsection[{release}]{\setlength{\rightskip}{0pt plus 5cm}ckdb\-::\-Key\-Set $\ast$ kdb\-::\-Key\-Set\-::release (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KeySet_a2987b3fb1b12196399650726f1c18f02}
If you don't want destruction of keyset at the end you can release the pointer. \hypertarget{classkdb_1_1KeySet_a4476a586a48a64160c71ed480c681b19}{\index{kdb\-::\-Key\-Set@{kdb\-::\-Key\-Set}!rewind@{rewind}}
\index{rewind@{rewind}!kdb::KeySet@{kdb\-::\-Key\-Set}}
\subsubsection[{rewind}]{\setlength{\rightskip}{0pt plus 5cm}void kdb\-::\-Key\-Set\-::rewind (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KeySet_a4476a586a48a64160c71ed480c681b19}




Rewinds the \hyperlink{classkdb_1_1KeySet}{Key\-Set} internal cursor.

Use it to set the cursor to the beginning of the \hyperlink{classkdb_1_1KeySet}{Key\-Set}. \hyperlink{group__keyset_ga4287b9416912c5f2ab9c195cb74fb094}{ks\-Current()} will then always return N\-U\-L\-L afterwards. So you want to \hyperlink{group__keyset_ga317321c9065b5a4b3e33fe1c399bcec9}{ks\-Next()} first.


\begin{DoxyCode}
\hyperlink{group__keyset_gabe793ff51f1728e3429c84a8a9086b70}{ksRewind} (ks);
\textcolor{keywordflow}{while} ((key = \hyperlink{group__keyset_ga317321c9065b5a4b3e33fe1c399bcec9}{ksNext} (ks))!=0) \{\}
\end{DoxyCode}



\begin{DoxyParams}{Parameters}
{\em ks} & the keyset object to work with \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success 

-\/1 on N\-U\-L\-L pointer 
\end{DoxyReturn}
\begin{DoxySeeAlso}{See Also}
\hyperlink{group__keyset_ga317321c9065b5a4b3e33fe1c399bcec9}{ks\-Next()}, \hyperlink{group__keyset_ga4287b9416912c5f2ab9c195cb74fb094}{ks\-Current()} 
\end{DoxySeeAlso}
 \hypertarget{classkdb_1_1KeySet_a844be268914882e5159424e9ee302119}{\index{kdb\-::\-Key\-Set@{kdb\-::\-Key\-Set}!set\-Cursor@{set\-Cursor}}
\index{set\-Cursor@{set\-Cursor}!kdb::KeySet@{kdb\-::\-Key\-Set}}
\subsubsection[{set\-Cursor}]{\setlength{\rightskip}{0pt plus 5cm}void kdb\-::\-Key\-Set\-::set\-Cursor (
\begin{DoxyParamCaption}
\item[{cursor\-\_\-t}]{cursor}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KeySet_a844be268914882e5159424e9ee302119}




Set the \hyperlink{classkdb_1_1KeySet}{Key\-Set} internal cursor.

Use it to set the cursor to a stored position. \hyperlink{group__keyset_ga4287b9416912c5f2ab9c195cb74fb094}{ks\-Current()} will then be the position which you got with.

\begin{DoxyWarning}{Warning}
Cursors may get invalid when the key was \hyperlink{group__keyset_gae42530b04defb772059de0600159cf69}{ks\-Pop()}ed or \hyperlink{group__keyset_gaa34fc43a081e6b01e4120daa6c112004}{ks\-Lookup()} was used together with K\-D\-B\-\_\-\-O\-\_\-\-P\-O\-P.
\end{DoxyWarning}

\begin{DoxyCode}
cursor\_t cursor;
..
\textcolor{comment}{// key now in any position here}
cursor = \hyperlink{group__keyset_gaffe507ab9281c322eb16c3e992075d29}{ksGetCursor} (ks);
\textcolor{keywordflow}{while} ((key = \hyperlink{group__keymeta_ga4c88342f580a4291455a801af71ce048}{keyNextMeta} (ks))!=0) \{\}
\hyperlink{group__keyset_gad94c9ffaa3e8034564c0712fd407c345}{ksSetCursor} (ks, cursor); \textcolor{comment}{// reset state}
\hyperlink{group__keyset_ga4287b9416912c5f2ab9c195cb74fb094}{ksCurrent}(ks); \textcolor{comment}{// in same position as before}
\end{DoxyCode}


An invalid cursor will set the keyset to its beginning like \hyperlink{group__keyset_gabe793ff51f1728e3429c84a8a9086b70}{ks\-Rewind()}. When you set an invalid cursor \hyperlink{group__keyset_ga4287b9416912c5f2ab9c195cb74fb094}{ks\-Current()} is 0 and \hyperlink{group__keyset_ga317321c9065b5a4b3e33fe1c399bcec9}{ks\-Next()} == \hyperlink{group__keyset_gae7dbf3aef70e67b5328475eb3d1f92f5}{ks\-Head()}.


\begin{DoxyParams}{Parameters}
{\em cursor} & the cursor to use \\
\hline
{\em ks} & the keyset object to work with \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 when the keyset is \hyperlink{group__keyset_gabe793ff51f1728e3429c84a8a9086b70}{ks\-Rewind()}ed 

1 otherwise 

-\/1 on N\-U\-L\-L pointer 
\end{DoxyReturn}
\begin{DoxySeeAlso}{See Also}
\hyperlink{group__keyset_ga317321c9065b5a4b3e33fe1c399bcec9}{ks\-Next()}, \hyperlink{group__keyset_gaffe507ab9281c322eb16c3e992075d29}{ks\-Get\-Cursor()} 
\end{DoxySeeAlso}
 \hypertarget{classkdb_1_1KeySet_a9f3ec4eebe304185527b08a6fa01b77c}{\index{kdb\-::\-Key\-Set@{kdb\-::\-Key\-Set}!set\-Key\-Set@{set\-Key\-Set}}
\index{set\-Key\-Set@{set\-Key\-Set}!kdb::KeySet@{kdb\-::\-Key\-Set}}
\subsubsection[{set\-Key\-Set}]{\setlength{\rightskip}{0pt plus 5cm}void kdb\-::\-Key\-Set\-::set\-Key\-Set (
\begin{DoxyParamCaption}
\item[{ckdb\-::\-Key\-Set $\ast$}]{k}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KeySet_a9f3ec4eebe304185527b08a6fa01b77c}


Take ownership of passed keyset. 


\begin{DoxyParams}{Parameters}
{\em k} & the keyset to take ownership from \\
\hline
\end{DoxyParams}
\begin{DoxySeeAlso}{See Also}
\hyperlink{classkdb_1_1KeySet_a2987b3fb1b12196399650726f1c18f02}{release()} 

\hyperlink{classkdb_1_1KeySet_aa79bbbfb6e2f3e9c48cb3e595f9cda51}{get\-Key\-Set()} 
\end{DoxySeeAlso}
\hypertarget{classkdb_1_1KeySet_a18b332fe23a7f793f80f9b22b5727584}{\index{kdb\-::\-Key\-Set@{kdb\-::\-Key\-Set}!size@{size}}
\index{size@{size}!kdb::KeySet@{kdb\-::\-Key\-Set}}
\subsubsection[{size}]{\setlength{\rightskip}{0pt plus 5cm}ssize\-\_\-t kdb\-::\-Key\-Set\-::size (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KeySet_a18b332fe23a7f793f80f9b22b5727584}


The size of the keyset. 

\begin{DoxyReturn}{Returns}
the number of keys in the keyset 
\end{DoxyReturn}
\hypertarget{classkdb_1_1KeySet_ac6ccd44a29326a0d9a5c2e60d3089b5e}{\index{kdb\-::\-Key\-Set@{kdb\-::\-Key\-Set}!tail@{tail}}
\index{tail@{tail}!kdb::KeySet@{kdb\-::\-Key\-Set}}
\subsubsection[{tail}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Key} kdb\-::\-Key\-Set\-::tail (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KeySet_ac6ccd44a29326a0d9a5c2e60d3089b5e}




\begin{DoxyReturn}{Returns}
alphabetical last key
\end{DoxyReturn}
Return the last key in the \hyperlink{classkdb_1_1KeySet}{Key\-Set}.

The Key\-Sets cursor will not be effected.

If \hyperlink{group__keyset_ga4287b9416912c5f2ab9c195cb74fb094}{ks\-Current()}==\hyperlink{group__keyset_gadca442c4ab43cf532b15091d7711559e}{ks\-Tail()} you know you are on the last key. \hyperlink{group__keyset_ga317321c9065b5a4b3e33fe1c399bcec9}{ks\-Next()} will return a N\-U\-L\-L pointer afterwards.


\begin{DoxyParams}{Parameters}
{\em ks} & the keyset object to work with \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the last \hyperlink{classkdb_1_1Key}{Key} of a keyset 

0 on N\-U\-L\-L pointer or empty keyset 
\end{DoxyReturn}
\begin{DoxySeeAlso}{See Also}
\hyperlink{group__keyset_gae7dbf3aef70e67b5328475eb3d1f92f5}{ks\-Head()} for the first \hyperlink{group__key}{Key} 

\hyperlink{group__keyset_gabe793ff51f1728e3429c84a8a9086b70}{ks\-Rewind()}, \hyperlink{group__keyset_ga4287b9416912c5f2ab9c195cb74fb094}{ks\-Current()} and \hyperlink{group__keyset_ga317321c9065b5a4b3e33fe1c399bcec9}{ks\-Next()} for iterating over the \hyperlink{group__keyset}{Key\-Set} 
\end{DoxySeeAlso}
 

The documentation for this class was generated from the following file\-:\begin{DoxyCompactItemize}
\item 
keyset.\-hpp\end{DoxyCompactItemize}
