OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "courgette/adjustment_method.h" | 5 #include "courgette/adjustment_method.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 LabelInfo* in_edge_; // | 142 LabelInfo* in_edge_; // |
143 Node* prev_; // Node at shorter length. | 143 Node* prev_; // Node at shorter length. |
144 int count_; // Frequency of this path in Trie. | 144 int count_; // Frequency of this path in Trie. |
145 int length_; | 145 int length_; |
146 typedef std::map<LabelInfo*, Node*> Edges; | 146 typedef std::map<LabelInfo*, Node*> Edges; |
147 Edges edges_; | 147 Edges edges_; |
148 std::vector<int> places_; // Indexes into sequence of this item. | 148 std::vector<int> places_; // Indexes into sequence of this item. |
149 std::list<Node*> edges_in_frequency_order; | 149 std::list<Node*> edges_in_frequency_order; |
150 | 150 |
151 bool in_queue_; | 151 bool in_queue_; |
152 bool Extended() const { return edges_.size() > 0; } | 152 bool Extended() const { return !edges_.empty(); } |
153 | 153 |
154 uint32 Weight() const { | 154 uint32 Weight() const { |
155 return edges_in_frequency_order.front()->count_; | 155 return edges_in_frequency_order.front()->count_; |
156 } | 156 } |
157 }; | 157 }; |
158 | 158 |
159 static std::string ToString(Node* node) { | 159 static std::string ToString(Node* node) { |
160 std::vector<std::string> prefix; | 160 std::vector<std::string> prefix; |
161 for (Node* n = node; n->prev_; n = n->prev_) | 161 for (Node* n = node; n->prev_; n = n->prev_) |
162 prefix.push_back(ToString(n->in_edge_)); | 162 prefix.push_back(ToString(n->in_edge_)); |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 AdjustmentMethod* method = AdjustmentMethod::MakeProductionAdjustmentMethod(); | 686 AdjustmentMethod* method = AdjustmentMethod::MakeProductionAdjustmentMethod(); |
687 bool ok = method->Adjust(model, program); | 687 bool ok = method->Adjust(model, program); |
688 method->Destroy(); | 688 method->Destroy(); |
689 if (ok) | 689 if (ok) |
690 return C_OK; | 690 return C_OK; |
691 else | 691 else |
692 return C_ADJUSTMENT_FAILED; | 692 return C_ADJUSTMENT_FAILED; |
693 } | 693 } |
694 | 694 |
695 } // namespace courgette | 695 } // namespace courgette |
OLD | NEW |