Ignore:
Timestamp:
Jul 30, 2019, 8:17:38 AM (3 years ago)
Author:
Peter
Message:

fixes #927. PriorityQueue? used an std::set internally, which meant it could only store unique elements. Fix this unexpected behaviour by using an std::multiset instead.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/0.16-stable/yat/utility/PriorityQueue.h

    r3792 r3829  
    44// $Id$
    55//
    6 // Copyright (C) 2015, 2016, 2017, 2018 Peter Johansson
     6// Copyright (C) 2015, 2016, 2017, 2018, 2019 Peter Johansson
    77//
    88// This program is free software; you can redistribute it and/or modify
     
    5656    : public detail::BasicQueue<PriorityQueue<T, Compare>
    5757                                , T
    58                                 , std::set<T, Compare> >
     58                                , std::multiset<T, Compare> >
    5959  {
    6060    friend class detail::BasicQueue<PriorityQueue<T, Compare>
    61                                     ,T,std::set<T,Compare> >;
     61                                    ,T,std::multiset<T,Compare> >;
    6262    typedef detail::BasicQueue<PriorityQueue<T, Compare>
    6363                               , T
    64                                , std::set<T,Compare> > Base;
     64                               , std::multiset<T,Compare> > Base;
    6565  public:
    6666    /**
     
    7373    */
    7474    explicit PriorityQueue(const Compare& comp)
    75       : Base(std::set<T, Compare>(comp)) {}
     75      : Base(std::multiset<T, Compare>(comp)) {}
    7676
    7777    /**
     
    9898      // has been popped and the element is lost. Instead we choose to
    9999      // return via passed reference.
    100       typename std::set<T, Compare>::iterator it = this->q_.end();
     100      typename std::multiset<T, Compare>::iterator it = this->q_.end();
    101101      YAT_ASSERT(this->q_.size());
    102102      --it;
Note: See TracChangeset for help on using the changeset viewer.