3 //=============================================================================
5 * @file Binary_Search.h
7 * Defines a binary search abstraction for friend records.
9 * @author Douglas C. Schmidt
11 //=============================================================================
14 #ifndef _BINARY_SEARCH_H
15 #define _BINARY_SEARCH_H
17 #include "Search_Struct.h"
20 * @class Binary_Search
22 * @brief Defines a binary search abstraction for friend records.
24 class Binary_Search
: public Search_Struct
27 /// Initialize the values for the iterators...
31 virtual ~Binary_Search ();
34 * Returns the next friend in the sequence of sorted friends. Note
35 * that this function would be simplified if we expanded the
36 * iterator interface to include an "initialize" and "next"
39 virtual Protocol_Record
*get_next_entry ();
42 * An iterator, similar to Binary_Search::get_next_friend, though in
43 * this case the friend records are returned in the order they
44 * appeared in the friend file, rather than in sorted order. Also,
45 * we skip over entries that don't have any hosts associated with
48 virtual Protocol_Record
*get_each_entry ();
51 * This function is used to merge the <key_name> from server
52 * <host_name> into the sorted list of userids kept on the client's
55 virtual Protocol_Record
*insert (const char *key_name
,
56 int max_len
= MAXUSERIDNAMELEN
) = 0;
58 /// This function is passed to qsort to perform the comparison
59 /// between login names for two friends.
60 static int name_compare (const void *, const void *);
63 Protocol_Record
**current_ptr_
;
66 Protocol_Record
*protocol_record_
;
67 Protocol_Record
**sorted_record_
;
73 #endif /* _BINARY_SEARCH_H */