Coverage Report

Created: 2025-11-11 06:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/aspell/common/basic_list.hpp
Line
Count
Source
1
#ifndef autil__basic_list_hh
2
#define autil__basic_list_hh
3
4
#include <list>
5
//#include <ext/slist>
6
7
//#include <assert.h>
8
9
// This file is part of The New Aspell
10
// Copyright (C) 2001 by Kevin Atkinson under the GNU LGPL license
11
// version 2.0 or 2.1.  You should have received a copy of the LGPL
12
// license along with this library if you did not you can find
13
// it at http://www.gnu.org/.
14
15
// BasicList is a simple list structure which can either be
16
//   implemented as a singly or doubly linked list.  I created it
17
//   because a Singly liked list is not part of the C++ standard however
18
//   the Doubly Linked list does not have the same methods as the doubly
19
//   linked list because the singly linked list has a bunch of special
20
//   methods to address the fact that it is far faster to insert
21
//   elements before the position pointed to by an iterator is far faster
22
//   than inserting elements after the current position which is what is
23
//   normally done.  Thus it is not possibly to simply substitute a singly
24
//   linked list with a doubly linked list by changing the name of the
25
//   container used.  This list currently acts as a wrapper for the list
26
//   (doubly linked list) STL class however it can also very easily be
27
//   written as a wrapper for the slist (singly linked list) class when
28
//   it is available (slist is part of the SGI STL but not the C++
29
//   standard) for better performance.
30
31
namespace acommon {
32
33
  template <typename T>
34
  class BasicList {
35
    //typedef __gnu_cxx::slist<T> List;
36
    typedef std::list<T> List;
37
    List data_;
38
  public:
39
    // treat the iterators as forward iterators only
40
    typedef typename List::iterator       iterator;
41
    typedef typename List::const_iterator const_iterator;
42
    typedef typename List::size_type      size_type;
43
45.8k
    bool empty() {return data_.empty();}
44
25.2k
    void clear() {data_.clear();}
45
    size_type size() {return data_.size();}
46
140k
    iterator begin() {return data_.begin();}
47
37.6M
    iterator end()   {return data_.end();}
48
    const_iterator begin() const {return data_.begin();}
49
    const_iterator end()   const {return data_.end();}
50
12.9M
    void push_front(const T & item) {data_.push_front(item);}
51
40.6k
    void pop_front() {data_.pop_front();}
52
12.9M
          T & front() {return data_.front();}
53
    const T & front() const {return data_.front();}
54
25.2k
    void swap(BasicList & other) {data_.swap(other.data_);}
55
53.3k
    void sort() {data_.sort();}
56
12.3k
    template<class Pred> void sort(Pred pr) {data_.sort(pr);}
57
    void splice_into (BasicList & other, iterator prev, iterator cur)
58
3.29M
    {
59
      //++prev;
60
      //assert (prev == cur);
61
3.29M
      data_.splice(data_.begin(),other.data_,cur);
62
      //data_.splice_after(data_.begin(), prev);
63
3.29M
    }
64
    template<class Pred>
65
609
    void merge(BasicList & other, Pred pr) {data_.merge(other.data_, pr);}
66
  };
67
68
}
69
70
#endif