Skip to content

Commit dd295e6

Browse files
pnkfelixalexcrichton
authored andcommitted
---
yaml --- r: 151717 b: refs/heads/try2 c: dbaf300 h: refs/heads/master i: 151715: 4071ee3 v: v3
1 parent 8314a6d commit dd295e6

File tree

2 files changed

+25
-21
lines changed

2 files changed

+25
-21
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 7f88cfde18942fc93c3f5952e51c03171446778c
8+
refs/heads/try2: dbaf300a91750b6f63cc607f8f19405cf3d6671f
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/middle/graph.rs

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,14 @@ pub static Incoming: Direction = Direction { repr: 1 };
7070

7171
impl NodeIndex {
7272
fn get(&self) -> uint { let NodeIndex(v) = *self; v }
73+
/// Returns unique id (unique with respect to the graph holding associated node).
74+
pub fn node_id(&self) -> uint { self.get() }
7375
}
7476

7577
impl EdgeIndex {
7678
fn get(&self) -> uint { let EdgeIndex(v) = *self; v }
79+
/// Returns unique id (unique with respect to the graph holding associated edge).
80+
pub fn edge_id(&self) -> uint { self.get() }
7781
}
7882

7983
impl<N,E> Graph<N,E> {
@@ -201,39 +205,39 @@ impl<N,E> Graph<N,E> {
201205
///////////////////////////////////////////////////////////////////////////
202206
// Iterating over nodes, edges
203207

204-
pub fn each_node(&self, f: |NodeIndex, &Node<N>| -> bool) -> bool {
208+
pub fn each_node<'a>(&'a self, f: |NodeIndex, &'a Node<N>| -> bool) -> bool {
205209
//! Iterates over all edges defined in the graph.
206210
self.nodes.iter().enumerate().advance(|(i, node)| f(NodeIndex(i), node))
207211
}
208212

209-
pub fn each_edge(&self, f: |EdgeIndex, &Edge<E>| -> bool) -> bool {
213+
pub fn each_edge<'a>(&'a self, f: |EdgeIndex, &'a Edge<E>| -> bool) -> bool {
210214
//! Iterates over all edges defined in the graph
211215
self.edges.iter().enumerate().advance(|(i, edge)| f(EdgeIndex(i), edge))
212216
}
213217

214-
pub fn each_outgoing_edge(&self,
215-
source: NodeIndex,
216-
f: |EdgeIndex, &Edge<E>| -> bool)
217-
-> bool {
218+
pub fn each_outgoing_edge<'a>(&'a self,
219+
source: NodeIndex,
220+
f: |EdgeIndex, &'a Edge<E>| -> bool)
221+
-> bool {
218222
//! Iterates over all outgoing edges from the node `from`
219223
220224
self.each_adjacent_edge(source, Outgoing, f)
221225
}
222226

223-
pub fn each_incoming_edge(&self,
224-
target: NodeIndex,
225-
f: |EdgeIndex, &Edge<E>| -> bool)
226-
-> bool {
227+
pub fn each_incoming_edge<'a>(&'a self,
228+
target: NodeIndex,
229+
f: |EdgeIndex, &'a Edge<E>| -> bool)
230+
-> bool {
227231
//! Iterates over all incoming edges to the node `target`
228232
229233
self.each_adjacent_edge(target, Incoming, f)
230234
}
231235

232-
pub fn each_adjacent_edge(&self,
233-
node: NodeIndex,
234-
dir: Direction,
235-
f: |EdgeIndex, &Edge<E>| -> bool)
236-
-> bool {
236+
pub fn each_adjacent_edge<'a>(&'a self,
237+
node: NodeIndex,
238+
dir: Direction,
239+
f: |EdgeIndex, &'a Edge<E>| -> bool)
240+
-> bool {
237241
//! Iterates over all edges adjacent to the node `node`
238242
//! in the direction `dir` (either `Outgoing` or `Incoming)
239243
@@ -257,11 +261,11 @@ impl<N,E> Graph<N,E> {
257261
// variables or other bitsets. This method facilitates such a
258262
// computation.
259263

260-
pub fn iterate_until_fixed_point(&self,
261-
op: |iter_index: uint,
262-
edge_index: EdgeIndex,
263-
edge: &Edge<E>|
264-
-> bool) {
264+
pub fn iterate_until_fixed_point<'a>(&'a self,
265+
op: |iter_index: uint,
266+
edge_index: EdgeIndex,
267+
edge: &'a Edge<E>|
268+
-> bool) {
265269
let mut iteration = 0;
266270
let mut changed = true;
267271
while changed {

0 commit comments

Comments
 (0)