FlashGraph-ng
A new frontier in large-scale graph analysis and data mining
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
stl_algs.h
1 #ifndef __STL_ALGS_H__
2 #define __STL_ALGS_H__
3 
4 /*
5  * Copyright 2014 Open Connectome Project (http://openconnecto.me)
6  * Written by Da Zheng (zhengda1936@gmail.com)
7  *
8  * This file is part of FlashMatrix.
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  */
22 
23 #include <algorithm>
24 
25 namespace fm
26 {
27 
28 class stl_algs
29 {
30 public:
31  virtual off_t lower_bound(const char *start, const char *end,
32  const char *val) const = 0;
33 };
34 
35 template<class T>
36 class stl_algs_impl: public stl_algs
37 {
38 public:
39  virtual off_t lower_bound(const char *start, const char *end,
40  const char *val) const {
41  const T *t_start = (const T *) start;
42  const T *t_end = (const T *) end;
43  T t_val = *(const T *) val;
44  const T *ret = std::lower_bound(t_start, t_end, t_val);
45  return ret - t_start;
46  }
47 };
48 
49 }
50 
51 #endif