Skip to content

Commit 8acaf15

Browse files
committed
---
yaml --- r: 5989 b: refs/heads/master c: 506ae93 h: refs/heads/master i: 5987: c0cafda v: v3
1 parent f8ad538 commit 8acaf15

File tree

2 files changed

+36
-35
lines changed

2 files changed

+36
-35
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 2b85817af8bc4bdfbb155f15367c3ebee09eb743
2+
refs/heads/master: 506ae934f808c2cf664f289dc29f7e90d253a454

trunk/src/lib/vec.rs

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,41 @@ native "c-stack-cdecl" mod rustrt {
1919
count: uint) -> [T];
2020
}
2121

22+
/*
23+
Type: init_op
24+
25+
A function used to initialize the elements of a vector.
26+
*/
27+
type init_op<T> = block(uint) -> T;
28+
29+
30+
/*
31+
Predicate: is_empty
32+
33+
Returns true if a vector contains no elements.
34+
*/
35+
pure fn is_empty<T>(v: [mutable? T]) -> bool {
36+
// FIXME: This would be easier if we could just call len
37+
for t: T in v { ret false; }
38+
ret true;
39+
}
40+
41+
/*
42+
Predicate: is_not_empty
43+
44+
Returns true if a vector contains some elements.
45+
*/
46+
pure fn is_not_empty<T>(v: [mutable? T]) -> bool { ret !is_empty(v); }
47+
48+
/*
49+
Predicate: same_length
50+
51+
Returns true if two vectors have the same length
52+
*/
53+
pure fn same_length<T, U>(xs: [T], ys: [U]) -> bool {
54+
vec::len(xs) == vec::len(ys)
55+
}
56+
2257
/*
2358
Function: reserve
2459
@@ -43,13 +78,6 @@ Returns the length of a vector
4378
*/
4479
pure fn len<T>(v: [mutable? T]) -> uint { unchecked { rusti::vec_len(v) } }
4580

46-
/*
47-
Type: init_op
48-
49-
A function used to initialize the elements of a vector.
50-
*/
51-
type init_op<T> = block(uint) -> T;
52-
5381
/*
5482
Function: init_fn
5583
@@ -141,24 +169,6 @@ fn from_mut<T>(v: [mutable T]) -> [T] {
141169
ret vres;
142170
}
143171

144-
/*
145-
Predicate: is_empty
146-
147-
Returns true if a vector contains no elements.
148-
*/
149-
pure fn is_empty<T>(v: [mutable? T]) -> bool {
150-
// FIXME: This would be easier if we could just call len
151-
for t: T in v { ret false; }
152-
ret true;
153-
}
154-
155-
/*
156-
Predicate: is_not_empty
157-
158-
Returns true if a vector contains some elements.
159-
*/
160-
pure fn is_not_empty<T>(v: [mutable? T]) -> bool { ret !is_empty(v); }
161-
162172
// Accessors
163173

164174
/*
@@ -519,15 +529,6 @@ fn position_pred<T>(f: block(T) -> bool, v: [T]) -> option::t<uint> {
519529
ret none;
520530
}
521531

522-
/*
523-
Predicate: same_length
524-
525-
Returns true if two vectors have the same length
526-
*/
527-
pure fn same_length<T, U>(xs: [T], ys: [U]) -> bool {
528-
vec::len(xs) == vec::len(ys)
529-
}
530-
531532
// FIXME: if issue #586 gets implemented, could have a postcondition
532533
// saying the two result lists have the same length -- or, could
533534
// return a nominal record with a constraint saying that, instead of

0 commit comments

Comments
 (0)