• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDECore

Public Member Functions | List of all members
KSycocaDict Class Reference

#include <ksycocadict_p.h>

Public Member Functions

 KSycocaDict ()
 
 KSycocaDict (QDataStream *str, int offset)
 
 ~KSycocaDict ()
 
void add (const QString &key, const KSycocaEntry::Ptr &payload)
 
void clear ()
 
uint count () const
 
int find_string (const QString &key) const
 
QList< int > findMultiString (const QString &key) const
 
void remove (const QString &key)
 
void save (QDataStream &str)
 

Detailed Description

Hash table implementation for the sycoca database file

Only exported for the unit test

Definition at line 36 of file ksycocadict_p.h.

Constructor & Destructor Documentation

KSycocaDict::KSycocaDict ( )

Create an empty dict, for building the database.

Definition at line 77 of file ksycocadict.cpp.

KSycocaDict::KSycocaDict ( QDataStream *  str,
int  offset 
)

Create a dict from an existing database.

Definition at line 82 of file ksycocadict.cpp.

KSycocaDict::~KSycocaDict ( )

Definition at line 105 of file ksycocadict.cpp.

Member Function Documentation

void KSycocaDict::add ( const QString &  key,
const KSycocaEntry::Ptr &  payload 
)

Adds a 'payload' to the dictionary with key 'key'.

'payload' should have a valid offset by the time the dictionary gets saved.

Definition at line 111 of file ksycocadict.cpp.

void KSycocaDict::clear ( )

Reset the dictionary.

Only valid when building the database.

Definition at line 220 of file ksycocadict.cpp.

uint KSycocaDict::count ( ) const

The number of entries in the dictionary.

Only valid when building the database.

Definition at line 212 of file ksycocadict.cpp.

int KSycocaDict::find_string ( const QString &  key) const

Looks up an entry identified by 'key'.

If 0 is returned, no matching entry exists. Otherwise, the offset of the entry is returned.

NOTE: It is not guaranteed that this entry is indeed the one you were looking for. After loading the entry you should check that it indeed matches the search key. If it doesn't then no matching entry exists.

Definition at line 146 of file ksycocadict.cpp.

QList< int > KSycocaDict::findMultiString ( const QString &  key) const

Looks up all entries identified by 'key'.

This is useful when the dict is used as a multi-hash.

If an empty list is returned, no matching entry exists. Otherwise, the offset of the matching entries are returned.

NOTE: It is not guaranteed that each entry is indeed among the ones you were looking for. After loading each entry you should check that it indeed matches the search key.

Definition at line 181 of file ksycocadict.cpp.

void KSycocaDict::remove ( const QString &  key)

Removes the 'payload' from the dictionary with key 'key'.

Not very fast, use with care O(N)

Definition at line 125 of file ksycocadict.cpp.

void KSycocaDict::save ( QDataStream &  str)

Save the dictionary to the stream A reasonable fast hash algorithm will be created.

Typically this will find 90% of the entries directly. Average hash table size: nrOfItems * 20 bytes. Average duplicate list size: nrOfItms * avgKeyLength / 5.

Unknown keys have an average 20% chance to give a false hit. (That's why your program should check the result)

Example: Assume 1000 items with an average key length of 60 bytes.

Approx. 900 items will hash directly to the right entry. Approx. 100 items require a lookup in the duplicate list.

The hash table size will be approx. 20Kb. The duplicate list size will be approx. 12Kb.

Definition at line 331 of file ksycocadict.cpp.


The documentation for this class was generated from the following files:
  • ksycocadict_p.h
  • ksycocadict.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:47:11 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

Skip menu "KDECore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal