@@ -1570,15 +1570,19 @@ impl<T: Copy> &[const T]: CopyableVector<T> {
1570
1570
/// Returns the first element of a vector
1571
1571
#[ inline]
1572
1572
pure fn head ( ) -> T { head ( self ) }
1573
+
1573
1574
/// Returns all but the last elemnt of a vector
1574
1575
#[ inline]
1575
1576
pure fn init ( ) -> ~[ T ] { init ( self ) }
1577
+
1576
1578
/// Returns the last element of a `v`, failing if the vector is empty.
1577
1579
#[ inline]
1578
1580
pure fn last ( ) -> T { last ( self ) }
1581
+
1579
1582
/// Returns a copy of the elements from [`start`..`end`) from `v`.
1580
1583
#[ inline]
1581
1584
pure fn slice ( start : uint , end : uint ) -> ~[ T ] { slice ( self , start, end) }
1585
+
1582
1586
/// Returns all but the first element of a vector
1583
1587
#[ inline]
1584
1588
pure fn tail ( ) -> ~[ T ] { tail ( self ) }
@@ -1605,17 +1609,21 @@ pub trait ImmutableEqVector<T: Eq> {
1605
1609
/// Extension methods for vectors
1606
1610
impl < T > & [ T ] : ImmutableVector < T > {
1607
1611
/// Return a slice that points into another slice.
1612
+ #[ inline]
1608
1613
pure fn view ( start : uint , end : uint ) -> & self /[ T ] {
1609
1614
view ( self , start, end)
1610
1615
}
1616
+
1611
1617
/// Reduce a vector from right to left
1612
1618
#[ inline]
1613
1619
pure fn foldr < U : Copy > ( z : U , p : fn ( t : & T , u : U ) -> U ) -> U {
1614
1620
foldr ( self , z, p)
1615
1621
}
1622
+
1616
1623
/// Apply a function to each element of a vector and return the results
1617
1624
#[ inline]
1618
1625
pure fn map < U > ( f : fn ( t : & T ) -> U ) -> ~[ U ] { map ( self , f) }
1626
+
1619
1627
/**
1620
1628
* Apply a function to the index and value of each element in the vector
1621
1629
* and return the results
@@ -1757,66 +1765,82 @@ trait MutableEqVector<T: Eq> {
1757
1765
}
1758
1766
1759
1767
impl < T > ~[ T ] : MutableVector < T > {
1768
+ #[ inline]
1760
1769
fn push ( & mut self , t : T ) {
1761
1770
push ( self , t) ;
1762
1771
}
1763
1772
1773
+ #[ inline]
1764
1774
fn push_all_move ( & mut self , rhs : ~[ T ] ) {
1765
1775
push_all_move ( self , rhs) ;
1766
1776
}
1767
1777
1778
+ #[ inline]
1768
1779
fn pop ( & mut self ) -> T {
1769
1780
pop ( self )
1770
1781
}
1771
1782
1783
+ #[ inline]
1772
1784
fn shift ( & mut self ) -> T {
1773
1785
shift ( self )
1774
1786
}
1775
1787
1788
+ #[ inline]
1776
1789
fn unshift ( & mut self , x : T ) {
1777
1790
unshift ( self , x)
1778
1791
}
1779
1792
1793
+ #[ inline]
1780
1794
fn insert ( & mut self , i : uint , x : T ) {
1781
1795
insert ( self , i, x)
1782
1796
}
1783
1797
1798
+ #[ inline]
1784
1799
fn remove ( & mut self , i : uint ) -> T {
1785
1800
remove ( self , i)
1786
1801
}
1787
1802
1803
+ #[ inline]
1788
1804
fn swap_remove ( & mut self , index : uint ) -> T {
1789
1805
swap_remove ( self , index)
1790
1806
}
1791
1807
1808
+ #[ inline]
1792
1809
fn truncate ( & mut self , newlen : uint ) {
1793
1810
truncate ( self , newlen) ;
1794
1811
}
1795
1812
1813
+ #[ inline]
1796
1814
fn retain ( & mut self , f : pure fn( t : & T ) -> bool ) {
1797
1815
retain ( self , f) ;
1798
1816
}
1817
+
1799
1818
}
1800
1819
1801
1820
impl < T : Copy > ~[ T ] : MutableCopyableVector < T > {
1821
+ #[ inline]
1802
1822
fn push_all ( & mut self , rhs : & [ const T ] ) {
1803
1823
push_all ( self , rhs) ;
1804
1824
}
1805
1825
1826
+ #[ inline]
1806
1827
fn grow ( & mut self , n : uint , initval : & T ) {
1807
1828
grow ( self , n, initval) ;
1808
1829
}
1809
1830
1831
+ #[ inline]
1810
1832
fn grow_fn ( & mut self , n : uint , op : iter:: InitOp < T > ) {
1811
1833
grow_fn ( self , n, op) ;
1812
1834
}
1813
1835
1836
+ #[ inline]
1814
1837
fn grow_set ( & mut self , index : uint , initval : & T , val : T ) {
1815
1838
grow_set ( self , index, initval, val) ;
1816
1839
}
1817
1840
}
1818
1841
1819
1842
impl < T : Eq > ~[ T ] : MutableEqVector < T > {
1843
+ #[ inline]
1820
1844
fn dedup ( & mut self ) {
1821
1845
dedup ( self )
1822
1846
}
0 commit comments