libassa
3.5.1
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
assa
Repository.h
Go to the documentation of this file.
1
// -*- c++ -*-
2
//------------------------------------------------------------------------------
3
// Repository.h
4
//------------------------------------------------------------------------------
5
// Copyright (c) 2003 by Vladislav Grinchenko
6
//
7
// This library is free software; you can redistribute it and/or
8
// modify it under the terms of the GNU Library General Public
9
// License as published by the Free Software Foundation; either
10
// version 2 of the License, or (at your option) any later version.
11
//------------------------------------------------------------------------------
12
// Date: May 7, 2003
13
//------------------------------------------------------------------------------
14
15
#ifndef REPOSITORY_H
16
#define REPOSITORY_H
17
18
#include <vector>
19
using
std::vector;
20
21
namespace
ASSA {
22
32
template
<
typename
T>
33
class
Repository
34
{
35
public
:
36
typedef
T*
value_type
;
37
typedef
size_t
size_type
;
38
39
typedef
typename
std::vector<value_type>
list_t
;
40
typedef
typename
std::vector<value_type>::iterator
iterator
;
41
typedef
typename
std::vector<value_type>::const_iterator
const_iterator
;
42
45
Repository
() {
46
m_collection
=
new
list_t
;
47
}
48
50
virtual
~Repository
() {
51
if
(
m_collection
) {
clear
();
delete
m_collection
; }
52
}
53
55
iterator
begin
() {
return
m_collection
->begin (); }
56
58
const_iterator
begin
()
const
{
return
m_collection
->begin (); }
59
61
iterator
end
() {
return
m_collection
->end (); }
62
64
const_iterator
end
()
const
{
return
m_collection
->end (); }
65
67
bool
empty
()
const
{
return
m_collection
->empty (); }
68
70
size_type
size
()
const
{
return
m_collection
->size (); }
71
73
void
push_back
(
const
value_type
& x_) {
m_collection
->push_back (x_); }
74
76
void
erase
(
iterator
position_) {
m_collection
->erase (position_); }
77
81
bool
erase
(
const
value_type
& x_) {
82
iterator
it =
begin
();
83
while
(it !=
end
()) {
84
if
((*it) == x_) {
erase
(it);
break
; }
85
it++;
86
}
87
}
88
90
void
clear
() {
91
m_collection
->erase (
m_collection
->begin (),
m_collection
->end ());
92
}
93
94
private
:
95
list_t
*
m_collection
;
96
};
97
}
// @end namespace ASSA
98
99
#endif
/* REPOSITORY_H */
Generated on Tue Jun 19 2012 08:04:35 for libassa by
1.8.1.1