Guest User

Untitled

a guest
Feb 19th, 2013
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. #ifndef __INVERTEDINDEX_H__
  2. #define __INVERTEDINDEX_H__
  3.  
  4. #define rest 5381
  5.  
  6. typedef struct Array {
  7.     int     *v;
  8.     int     n, cap;
  9. } Array_t;
  10.  
  11. typedef struct Entry {
  12.     char    *word;
  13.     Array_t   documents;
  14. } Entry_t;
  15.  
  16. typedef struct Node {
  17.     struct Node      *next;
  18.     Entry_t          data;
  19. } Node_t, *ANode_t;
  20.  
  21. typedef struct Map {
  22.     Node_t    **buckets;
  23.     int     size;
  24. } Map_t;
  25.  
  26. unsigned long hash(unsigned char *str)
  27. {
  28.     unsigned long hash = rest;
  29.     int c;
  30.  
  31.     while((c = *str++)) {
  32.         hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
  33.     }
  34.  
  35.     return hash;
  36. }
  37.  
  38. void put_doc(Map_t *map, char *key, int docID);
  39.  
  40. Array_t get_docs(Map_t *map, char *key);
  41.  
  42. Array_t intersection(const Array_t files1, const Array_t files2);
  43.  
  44. Array_t reunion(const Array_t files1, const Array_t files2);
  45.  
  46. void solve();
  47.  
  48. #endif
Advertisement
Add Comment
Please, Sign In to add comment