Skip to content

Commit 727116c

Browse files
committed
---
yaml --- r: 61317 b: refs/heads/try c: cf0f760 h: refs/heads/master i: 61315: 42e90de v: v3
1 parent bab2853 commit 727116c

File tree

4 files changed

+153
-111
lines changed

4 files changed

+153
-111
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2d28d645422c1617be58c8ca7ad9a457264ca850
5-
refs/heads/try: 7e4a176dd3a1789d5d10cb995a62daa185cb9cdd
5+
refs/heads/try: cf0f760560385d59427e2b974f24a328345d829b
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libcore/vec.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,6 +2071,8 @@ pub trait ImmutableVector<'self, T> {
20712071
fn initn(&self, n: uint) -> &'self [T];
20722072
fn last(&self) -> &'self T;
20732073
fn last_opt(&self) -> Option<&'self T>;
2074+
fn position(&self, f: &fn(t: &T) -> bool) -> Option<uint>;
2075+
fn rposition(&self, f: &fn(t: &T) -> bool) -> Option<uint>;
20742076
#[cfg(stage0)]
20752077
fn each_reverse(&self, blk: &fn(&T) -> bool);
20762078
#[cfg(not(stage0))]
@@ -2138,6 +2140,30 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] {
21382140
#[inline]
21392141
fn last_opt(&self) -> Option<&'self T> { last_opt(*self) }
21402142

2143+
/**
2144+
* Find the first index matching some predicate
2145+
*
2146+
* Apply function `f` to each element of `v`. When function `f` returns
2147+
* true then an option containing the index is returned. If `f` matches no
2148+
* elements then none is returned.
2149+
*/
2150+
#[inline]
2151+
fn position(&self, f: &fn(t: &T) -> bool) -> Option<uint> {
2152+
position(*self, f)
2153+
}
2154+
2155+
/**
2156+
* Find the last index matching some predicate
2157+
*
2158+
* Apply function `f` to each element of `v` in reverse order. When
2159+
* function `f` returns true then an option containing the index is
2160+
* returned. If `f` matches no elements then none is returned.
2161+
*/
2162+
#[inline]
2163+
fn rposition(&self, f: &fn(t: &T) -> bool) -> Option<uint> {
2164+
rposition(*self, f)
2165+
}
2166+
21412167
/// Iterates over a vector's elements in reverse.
21422168
#[inline]
21432169
#[cfg(stage0)]
@@ -2230,43 +2256,17 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] {
22302256
}
22312257

22322258
pub trait ImmutableEqVector<T:Eq> {
2233-
fn position(&self, f: &fn(t: &T) -> bool) -> Option<uint>;
22342259
fn position_elem(&self, t: &T) -> Option<uint>;
2235-
fn rposition(&self, f: &fn(t: &T) -> bool) -> Option<uint>;
22362260
fn rposition_elem(&self, t: &T) -> Option<uint>;
22372261
}
22382262

22392263
impl<'self,T:Eq> ImmutableEqVector<T> for &'self [T] {
2240-
/**
2241-
* Find the first index matching some predicate
2242-
*
2243-
* Apply function `f` to each element of `v`. When function `f` returns
2244-
* true then an option containing the index is returned. If `f` matches no
2245-
* elements then none is returned.
2246-
*/
2247-
#[inline]
2248-
fn position(&self, f: &fn(t: &T) -> bool) -> Option<uint> {
2249-
position(*self, f)
2250-
}
2251-
22522264
/// Find the first index containing a matching value
22532265
#[inline]
22542266
fn position_elem(&self, x: &T) -> Option<uint> {
22552267
position_elem(*self, x)
22562268
}
22572269

2258-
/**
2259-
* Find the last index matching some predicate
2260-
*
2261-
* Apply function `f` to each element of `v` in reverse order. When
2262-
* function `f` returns true then an option containing the index is
2263-
* returned. If `f` matches no elements then none is returned.
2264-
*/
2265-
#[inline]
2266-
fn rposition(&self, f: &fn(t: &T) -> bool) -> Option<uint> {
2267-
rposition(*self, f)
2268-
}
2269-
22702270
/// Find the last index containing a matching value
22712271
#[inline]
22722272
fn rposition_elem(&self, t: &T) -> Option<uint> {

branches/try/src/libstd/num/bigint.rs

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ A BigInt is a combination of BigUint and Sign.
1717
*/
1818

1919
use core::cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering, Less, Equal, Greater};
20-
use core::num::{IntConvertible, Zero, One, ToStrRadix, FromStrRadix};
20+
use core::num::{IntConvertible, Zero, One, ToStrRadix, FromStrRadix, Orderable};
2121

2222
/**
2323
A BigDigit is a BigUint's composing element.
@@ -144,6 +144,26 @@ impl FromStr for BigUint {
144144
}
145145
}
146146

147+
impl Num for BigUint {}
148+
149+
impl Orderable for BigUint {
150+
#[inline(always)]
151+
fn min(&self, other: &BigUint) -> BigUint {
152+
if self < other { self.clone() } else { other.clone() }
153+
}
154+
155+
#[inline(always)]
156+
fn max(&self, other: &BigUint) -> BigUint {
157+
if self > other { self.clone() } else { other.clone() }
158+
}
159+
160+
#[inline(always)]
161+
fn clamp(&self, mn: &BigUint, mx: &BigUint) -> BigUint {
162+
if self > mx { mx.clone() } else
163+
if self < mn { mn.clone() } else { self.clone() }
164+
}
165+
}
166+
147167
impl Shl<uint, BigUint> for BigUint {
148168
#[inline(always)]
149169
fn shl(&self, rhs: &uint) -> BigUint {
@@ -788,6 +808,26 @@ impl FromStr for BigInt {
788808
}
789809
}
790810

811+
impl Num for BigInt {}
812+
813+
impl Orderable for BigInt {
814+
#[inline(always)]
815+
fn min(&self, other: &BigInt) -> BigInt {
816+
if self < other { self.clone() } else { other.clone() }
817+
}
818+
819+
#[inline(always)]
820+
fn max(&self, other: &BigInt) -> BigInt {
821+
if self > other { self.clone() } else { other.clone() }
822+
}
823+
824+
#[inline(always)]
825+
fn clamp(&self, mn: &BigInt, mx: &BigInt) -> BigInt {
826+
if self > mx { mx.clone() } else
827+
if self < mn { mn.clone() } else { self.clone() }
828+
}
829+
}
830+
791831
impl Shl<uint, BigInt> for BigInt {
792832
#[inline(always)]
793833
fn shl(&self, rhs: &uint) -> BigInt {

0 commit comments

Comments
 (0)