ProteoWizard
MemoryIndex.hpp
Go to the documentation of this file.
1//
2// $Id$
3//
4//
5// Original author: Matt Chambers <matt.chambers .@. vanderbilt.edu>
6//
7// Copyright 2009 Vanderbilt University - Nashville, TN 37232
8//
9// Licensed under the Apache License, Version 2.0 (the "License");
10// you may not use this file except in compliance with the License.
11// You may obtain a copy of the License at
12//
13// http://www.apache.org/licenses/LICENSE-2.0
14//
15// Unless required by applicable law or agreed to in writing, software
16// distributed under the License is distributed on an "AS IS" BASIS,
17// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18// See the License for the specific language governing permissions and
19// limitations under the License.
20//
21
22#ifndef _MEMORYINDEX_HPP_
23#define _MEMORYINDEX_HPP_
24
25
26#include "Index.hpp"
27
28
29namespace pwiz {
30namespace data {
31
32
33/// index implementation in memory;
34/// find(string id) is O(logN);
35/// find(ordinal index) is O(1);
36/// memory footprint is basically (number of entries * 2)
38{
39 public:
40
42
43 virtual void create(std::vector<Entry>& entries);
44 virtual size_t size() const;
45 virtual EntryPtr find(const std::string& id) const;
46 virtual EntryPtr find(size_t index) const;
47
48 private:
49 class Impl;
50 boost::shared_ptr<Impl> impl_;
51};
52
53
54} // namespace data
55} // namespace pwiz
56
57
58#endif // _MEMORYINDEX_HPP_
#define PWIZ_API_DECL
Definition Export.hpp:32
generic interface for creating and using an index on a stream of serialized objects
Definition Index.hpp:40
boost::shared_ptr< Entry > EntryPtr
Definition Index.hpp:53
index implementation in memory; find(string id) is O(logN); find(ordinal index) is O(1); memory footp...
boost::shared_ptr< Impl > impl_
virtual EntryPtr find(size_t index) const
returns the entry for the specified ordinal index, or null if the ordinal is not in the index
virtual void create(std::vector< Entry > &entries)
create the index from specified list of entries; the list is non-const because the index implementati...
virtual size_t size() const
returns the number of entries in the index
virtual EntryPtr find(const std::string &id) const
returns the entry for the specified string id, or null if the id is not in the index