Yurttas/PL/OOL/Cplusplus/F/05/04/03/00/search.cpp

 1/*
 2   Copyright(C) 2002
 3   All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
 4
 5   Permission to use, copy, modify, and distribute this
 6   software and its documentation for EDUCATIONAL purposes
 7   and without fee is hereby granted provided that this
 8   copyright notice appears in all copies.
 9
10   date   : January 1, 2002.
11   authorĀ : Salih Yurttas.
12
13   search.cpp
14*/
15
16
17#include "search.h"
18
19using namespace std;
20
21template <class T>
22void search(vector<T>& list) {
23  get_vector_item(list);
24
25  bool found;
26
27  T key;
28
29  get_item(key);
30
31  char search_decision = get_char("Linear|Binary");
32
33  switch(toupper(search_decision)) {
34    case Linear : found = linear_search(key,
35                                        list);
36                  break;
37    case Binary : found = binary_search(key,
38                                        list);
39                  break;
40    default : cerr << "Error: search_decision should be L|B" << endl;
41              exit(1);
42  }
43
44  put_found_item(found,
45                 key);
46}