root/tlate/thread_value.cc
| Revision 62c7c77e091368d89d5f9699dd6185177dd37f4b, 2.0 KB (checked in by Antti-Juhani Kaijanaho <antti-juhani@…>, 21 months ago) | |
|---|---|
|
|
| Line | |
|---|---|
| 1 | /* This file is part of Alue, the multiprotocol Internet discussion daemon |
| 2 | |
| 3 | Copyright © 2009, 2010 Antti-Juhani Kaijanaho |
| 4 | |
| 5 | Alue is free software: you can redistribute it and/or modify it |
| 6 | under the terms of the GNU General Public License as published by |
| 7 | the Free Software Foundation, either version 3 of the License, or |
| 8 | (at your option) any later version. |
| 9 | |
| 10 | Alue is distributed in the hope that it will be useful, but |
| 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU General Public License |
| 16 | along with Alue. If not, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | */ |
| 19 | |
| 20 | #include "thread_value.hh" |
| 21 | |
| 22 | #include <list> |
| 23 | |
| 24 | namespace tlate |
| 25 | { |
| 26 | thread_value::thread_value(db::thread_node::const_ptr tn, |
| 27 | boost::shared_ptr<const db::user> u) |
| 28 | : u(u) |
| 29 | { |
| 30 | typedef std::list<db::thread_node::ptr> tlnc; |
| 31 | |
| 32 | tnl.push_back(tn); |
| 33 | for (size_t i = 0; i < tnl.size(); i++) |
| 34 | { |
| 35 | const tlnc &itch = tnl[i]->get_children(); |
| 36 | for (tlnc::const_iterator jt = itch.begin(); |
| 37 | jt != itch.end(); jt++) |
| 38 | { |
| 39 | tnl.push_back(*jt); |
| 40 | } |
| 41 | } |
| 42 | std::stable_sort(tnl.begin(), tnl.end(), |
| 43 | db::thread_node::cmp_date); |
| 44 | } |
| 45 | void thread_value::slice_window(size_t start, size_t length) |
| 46 | { |
| 47 | if (start > tnl.size()) |
| 48 | { |
| 49 | tnl.clear(); |
| 50 | return; |
| 51 | } |
| 52 | if (start > 0) tnl.erase(tnl.begin(), tnl.begin()+start); |
| 53 | if (length < tnl.size()) |
| 54 | tnl.erase(tnl.begin()+length, tnl.end()); |
| 55 | } |
| 56 | } |
Note: See TracBrowser
for help on using the browser.
