grelationaltable.h

来自「一个由Mike Gashler完成的机器学习方面的includes neural」· C头文件 代码 · 共 79 行

H
79
字号
#ifndef __GRELATIONALTABLE_H__#define __GRELATIONALTABLE_H__class GAVLTree;class GAVLNode;class GAVLEnumerator;class GRelationalTable;class GRelationalTableNode;typedef int (*GRelationalTableFieldComparerFunc)(const void* pObjA, const void* pObjB);// This enumerates the results returned by GRelationalTable::Queryclass GRelationalTableEnumerator{friend class GRelationalTable;protected:	GAVLEnumerator* m_pFieldEnumerator;	GRelationalTableNode* m_pInternalModel;public:	GRelationalTableEnumerator();	~GRelationalTableEnumerator();	// Returns the next object in the results. Returns NULL if there	// are no more objects.	void* GetNext();	// This is an internal method. You shouldn't ever call it. The GRelationalTable	// uses it when you perform a query to initialize the enumerator.	void InternalInit(GAVLTree* pField, GRelationalTableFieldComparerFunc pCompareFunc, const void* pObj);};// A GRelationalTable is similar to a table in a relational database, except that// it is done entirely in memory, not on disk. Instead of rows, it holds// a collection of objects. Each object is indexed in all of the fields// that the table defines. Since the virtual memory of the operating system// will swap unused pages out to disk anyway, it actually behaves almost// exactly like a table in a relational database, but it's much easier to// work with.class GRelationalTable{protected:	int m_nFields;	GAVLTree* m_pFields;	GRelationalTableFieldComparerFunc* m_pComparers;public:	GRelationalTable(int nFields, const GRelationalTableFieldComparerFunc pCompareFuncs[]);	~GRelationalTable();#ifndef NO_TEST_CODE	static void Test();#endif // NO_TEST_CODE	// Adds an object to the table (and indexes all of its fields)	void AddRow(const void* pObj);	// This method initializes pEnumerator to point to the first object where	// field "nField" matches the same field of "pModelObj". To get the results	// of the query, just call pEnumerator->GetNext() until you're done. It's	// okay to reuse the same GRelationalTableEnumerator object for multiple queries. (A	// good implementation is often to make pModelObj an instance of some base	// class and all the objects in the table instances of a class that inherits	// from that base class. This way the compare funcs can operate on the	// base class, but the model objects don't need a full payload.)	void Query(GRelationalTableEnumerator* pEnumerator, int nField, const void* pModelObj);};#endif // __GRELATIONALTABLE_H__

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?