@@ -1171,134 +1171,6 @@ impl_multiplicative! { uint, 1 }
11711171impl_multiplicative ! { f32 , 1.0 }
11721172impl_multiplicative ! { f64 , 1.0 }
11731173
1174- <<<<<<< HEAD
1175- =======
1176- /// A trait for iterators over elements which can be compared to one another.
1177- #[ unstable = "recently renamed for new extension trait conventions" ]
1178- pub trait IteratorOrdExt < A > {
1179- /// Consumes the entire iterator to return the maximum element.
1180- ///
1181- /// # Example
1182- ///
1183- /// ```rust
1184- /// let a = [1i, 2, 3, 4, 5];
1185- /// assert!(a.iter().max().unwrap() == &5);
1186- /// ```
1187- fn max ( self ) -> Option < A > ;
1188-
1189- /// Consumes the entire iterator to return the minimum element.
1190- ///
1191- /// # Example
1192- ///
1193- /// ```rust
1194- /// let a = [1i, 2, 3, 4, 5];
1195- /// assert!(a.iter().min().unwrap() == &1);
1196- /// ```
1197- fn min ( self ) -> Option < A > ;
1198-
1199- /// `min_max` finds the minimum and maximum elements in the iterator.
1200- ///
1201- /// The return type `MinMaxResult` is an enum of three variants:
1202- ///
1203- /// - `NoElements` if the iterator is empty.
1204- /// - `OneElement(x)` if the iterator has exactly one element.
1205- /// - `MinMax(x, y)` is returned otherwise, where `x <= y`. Two
1206- /// values are equal if and only if there is more than one
1207- /// element in the iterator and all elements are equal.
1208- ///
1209- /// On an iterator of length `n`, `min_max` does `1.5 * n` comparisons,
1210- /// and so is faster than calling `min` and `max` separately which does `2 * n` comparisons.
1211- ///
1212- /// # Example
1213- ///
1214- /// ```rust
1215- /// use std::iter::MinMaxResult::{NoElements, OneElement, MinMax};
1216- ///
1217- /// let v: [int; 0] = [];
1218- /// assert_eq!(v.iter().min_max(), NoElements);
1219- ///
1220- /// let v = [1i];
1221- /// assert!(v.iter().min_max() == OneElement(&1));
1222- ///
1223- /// let v = [1i, 2, 3, 4, 5];
1224- /// assert!(v.iter().min_max() == MinMax(&1, &5));
1225- ///
1226- /// let v = [1i, 2, 3, 4, 5, 6];
1227- /// assert!(v.iter().min_max() == MinMax(&1, &6));
1228- ///
1229- /// let v = [1i, 1, 1, 1];
1230- /// assert!(v.iter().min_max() == MinMax(&1, &1));
1231- /// ```
1232- fn min_max ( self ) -> MinMaxResult < A > ;
1233- }
1234-
1235- #[ unstable = "trait is unstable" ]
1236- impl < T , I > IteratorOrdExt < T > for I where I : Iterator < Item =T > , T : Ord {
1237- #[ inline]
1238- fn max ( self ) -> Option < T > {
1239- self . fold ( None , |max, x| {
1240- match max {
1241- None => Some ( x) ,
1242- Some ( y) => Some ( cmp:: max ( x, y) )
1243- }
1244- } )
1245- }
1246-
1247- #[ inline]
1248- fn min ( self ) -> Option < T > {
1249- self . fold ( None , |min, x| {
1250- match min {
1251- None => Some ( x) ,
1252- Some ( y) => Some ( cmp:: min ( x, y) )
1253- }
1254- } )
1255- }
1256-
1257- fn min_max ( mut self ) -> MinMaxResult < T > {
1258- let ( mut min, mut max) = match self . next ( ) {
1259- None => return NoElements ,
1260- Some ( x) => {
1261- match self . next ( ) {
1262- None => return OneElement ( x) ,
1263- Some ( y) => if x < y { ( x, y) } else { ( y, x) }
1264- }
1265- }
1266- } ;
1267-
1268- loop {
1269- // `first` and `second` are the two next elements we want to look at.
1270- // We first compare `first` and `second` (#1). The smaller one is then compared to
1271- // current minimum (#2). The larger one is compared to current maximum (#3). This
1272- // way we do 3 comparisons for 2 elements.
1273- let first = match self . next ( ) {
1274- None => break ,
1275- Some ( x) => x
1276- } ;
1277- let second = match self . next ( ) {
1278- None => {
1279- if first < min {
1280- min = first;
1281- } else if first > max {
1282- max = first;
1283- }
1284- break ;
1285- }
1286- Some ( x) => x
1287- } ;
1288- if first < second {
1289- if first < min { min = first; }
1290- if max < second { max = second; }
1291- } else {
1292- if second < min { min = second; }
1293- if max < first { max = first; }
1294- }
1295- }
1296-
1297- MinMax ( min, max)
1298- }
1299- }
1300-
1301- >>>>>>> parent of f031671... Remove i suffix in docs
13021174/// `MinMaxResult` is an enum returned by `min_max`. See `IteratorOrdExt::min_max` for more detail.
13031175#[ derive( Clone , PartialEq , Show ) ]
13041176#[ unstable = "unclear whether such a fine-grained result is widely useful" ]
@@ -1386,35 +1258,6 @@ impl<T, D, I> ExactSizeIterator for Cloned<I> where
13861258 I : ExactSizeIterator + Iterator < Item =D > ,
13871259{ }
13881260
1389- <<<<<<< HEAD
1390- =======
1391- #[ unstable = "recently renamed for extension trait conventions "]
1392- /// An extension trait for cloneable iterators.
1393- pub trait CloneIteratorExt {
1394- /// Repeats an iterator endlessly
1395- ///
1396- /// # Example
1397- ///
1398- /// ```rust
1399- /// use std::iter::{CloneIteratorExt, count};
1400- ///
1401- /// let a = count(1i,1i).take(1);
1402- /// let mut cy = a.cycle();
1403- /// assert_eq!(cy.next(), Some(1));
1404- /// assert_eq!(cy.next(), Some(1));
1405- /// ```
1406- #[ stable]
1407- fn cycle ( self ) -> Cycle < Self > ;
1408- }
1409-
1410- impl < I > CloneIteratorExt for I where I : Iterator + Clone {
1411- #[ inline]
1412- fn cycle ( self ) -> Cycle < I > {
1413- Cycle { orig : self . clone ( ) , iter : self }
1414- }
1415- }
1416-
1417- >>>>>>> parent of f031671... Remove i suffix in docs
14181261/// An iterator that repeats endlessly
14191262#[ derive( Clone , Copy ) ]
14201263#[ must_use = "iterator adaptors are lazy and do nothing unless consumed" ]
0 commit comments