/* $Id: select.hpp 1.1 1995/02/27 09:33:28 leon Exp leon $
*/

#ifndef afc_Selection_hpp

#define afc_Selection_hpp


#include "entity.h"

#include <ads/avltree.h>

#include <ads/adslib.h>


/**
 ** Izbor gradnikov in hitro iskanje po drevesu AVL
 ** Osnova je funkcija /Select/, ki iz baze Acad in filtra "X" naredi
 ** AVL drevo z imeni gradinikov /name/ in kljuci /key/.
 **/
class Selection
{
  AVLtree *root;
  struct ELEMENT
    {
      int number;
      ads_name name;
    };

  typedef void (*InOrder)(ads_name name);

public:

  Selection();
  virtual ~Selection();
  Select(struct resbuf *xFilter, 
         int (*getKey)(struct resbuf *rb, int *key),
         struct resbuf *rb);
  int Insert(int key, ads_name name);
  int Delete(int key);
  int Find(int key, ads_name name);
  void Print();
  void ForAll(void (*func) (ads_name name));

private:
  static void del(struct ELEMENT *element);
  static int compare(struct ELEMENT *el1, struct ELEMENT *el2);
  static void print(struct ELEMENT *element);
  static void inOrder(struct ELEMENT *element);
};


#endif



syntax highlighted by Code2HTML, v. 0.9.1