ProteoWizard
BinaryIndexStream.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 _BINARYINDEX_HPP_
23#define _BINARYINDEX_HPP_
24
25
26#include "Index.hpp"
27#include <iostream>
28
29
30namespace pwiz {
31namespace data {
32
33
34/// index implementation in a stream (intended for fstreams but any iostream works);
35/// find(string id) is O(logN);
36/// find(ordinal index) is O(1);
37/// memory footprint is negligible
39{
40 public:
41
42 BinaryIndexStream(boost::shared_ptr<std::iostream> indexStreamPtr);
43
44 virtual void create(std::vector<Entry>& entries);
45 virtual size_t size() const;
46 virtual EntryPtr find(const std::string& id) const;
47 virtual EntryPtr find(size_t index) const;
48
49 private:
50 class Impl;
51 boost::shared_ptr<Impl> impl_;
52};
53
54
55} // namespace data
56} // namespace pwiz
57
58
59#endif // _BINARYINDEX_HPP_
#define PWIZ_API_DECL
Definition Export.hpp:32
index implementation in a stream (intended for fstreams but any iostream works); find(string id) is O...
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
virtual size_t size() const
returns the number of entries in the index
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
BinaryIndexStream(boost::shared_ptr< std::iostream > indexStreamPtr)
boost::shared_ptr< Impl > impl_
virtual void create(std::vector< Entry > &entries)
create the index from specified list of entries; the list is non-const because the index implementati...
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