blob: 3036991ffa9101fd318da0e53693b2dd7979ee13 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
/* -*- C++ -*- */
//=============================================================================
/**
* @file Binary_Search.h
*
* Defines a binary search abstraction for friend records.
*
* @author Douglas C. Schmidt
*/
//=============================================================================
#ifndef _BINARY_SEARCH_H
#define _BINARY_SEARCH_H
#include "Search_Struct.h"
/**
* @class Binary_Search
*
* @brief Defines a binary search abstraction for friend records.
*/
class Binary_Search : public Search_Struct
{
public:
/// Initialize the values for the iterators...
Binary_Search (void);
/// Destructor.
virtual ~Binary_Search (void);
/**
* Returns the next friend in the sequence of sorted friends. Note
* that this function would be simplified if we expanded the
* iterator interface to include an "initialize" and "next"
* function!
*/
virtual Protocol_Record *get_next_entry (void);
/**
* An iterator, similar to Binary_Search::get_next_friend, though in
* this case the friend records are returned in the order they
* appeared in the friend file, rather than in sorted order. Also,
* we skip over entries that don't have any hosts associated with
* them.
*/
virtual Protocol_Record *get_each_entry (void);
/**
* This function is used to merge the <key_name> from server
* <host_name> into the sorted list of userids kept on the client's
* side.
*/
virtual Protocol_Record *insert (const char *key_name,
int max_len = MAXUSERIDNAMELEN) = 0;
/// This function is passed to qsort to perform the comparison
/// between login names for two friends.
static int name_compare (const void *, const void *);
protected:
Protocol_Record **current_ptr_;
int current_index_;
Protocol_Record *protocol_record_;
Protocol_Record **sorted_record_;
const char *buffer_;
int buffer_size_;
};
#endif /* _BINARY_SEARCH_H */
|