Method Gdbm.DB()->firstkey()
- Method
firstkey
string
firstkey()- Description
Return the first key in the database, this can be any key in the database.
Used together with nextkey the databse can be iterated.
- Note
The database also works as an Iterator, and can be used as the first argument to
foreach
.Adding or removing keys will change the iteration order, this can cause keys to be skipped while iterating.
- Example
// Write the contents of the database for(key=gdbm->firstkey(); k; k=gdbm->nextkey(k)) write(k+":"+gdbm->fetch(k)+"\n");
Or, using foreach
// Write the contents of the database foreach( db; string key; string value ) write(key+":"+value+"\n");