Changeset 3829


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.

Location:
branches/0.16-stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/0.16-stable/NEWS

    r3824 r3829  
    55yat 0.16.x series from http://dev.thep.lu.se/yat/svn/branches/0.16-stable
    66
    7 version 0.16 (released NOT YET)
     7version 0.16.1 (released NOT YET)
     8  - Fixed a bug that PriorityQueue could only store unique elements (see #927)
    89
    910  A complete list of closed tickets can be found here [[br]]
  • branches/0.16-stable/test/priority_queue.cc

    r3403 r3829  
    22
    33/*
    4   Copyright (C) 2015 Peter Johansson
     4  Copyright (C) 2015, 2019 Peter Johansson
    55
    66  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    9595  PriorityQueue<std::string, MyComp> queue2(comp);
    9696  queue2.push("hello");
     97  if (queue2.size() != 1) {
     98    suite.add(false);
     99    suite.err() << "incorrect size: " << queue2.size() << "; expected 1\n";
     100  }
     101  queue2.push("hello");
     102  if (queue2.size() != 2) {
     103    suite.add(false);
     104    suite.err() << "incorrect size: " << queue2.size() << "; expected 2\n";
     105  }
    97106
    98107  return suite.return_value();
  • 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.