OrderedCollection.st
changeset 4153 3481f2a3429c
parent 4064 fd3d2922fb8b
child 4427 8833e118ff25
equal deleted inserted replaced
4152:0c1780ae527f 4153:3481f2a3429c
   987 !OrderedCollection methodsFor:'converting'!
   987 !OrderedCollection methodsFor:'converting'!
   988 
   988 
   989 asArray 
   989 asArray 
   990     "return the receiver as an array."
   990     "return the receiver as an array."
   991 
   991 
   992     |newArray sz|
   992     ^ contentsArray copyFrom:firstIndex to:lastIndex
   993 
   993 
   994     sz := self size.
   994 "/    |newArray sz|
   995     newArray := Array new:sz.
   995 "/
   996     newArray replaceFrom:1 to:sz with:contentsArray startingAt:firstIndex.
   996 "/    sz := self size.
   997     ^ newArray
   997 "/    newArray := Array new:sz.
       
   998 "/    newArray replaceFrom:1 to:sz with:contentsArray startingAt:firstIndex.
       
   999 "/    ^ newArray
       
  1000 
       
  1001     "
       
  1002      OrderedCollection new asArray
       
  1003      OrderedCollection new add:1;add:2;asArray 
       
  1004      OrderedCollection new add:1;removeFirst;asArray 
       
  1005     "
   998 
  1006 
   999     "
  1007     "
  1000      |o rnd|
  1008      |o rnd|
  1001 
  1009 
  1002      o := OrderedCollection new.
  1010      o := OrderedCollection new.
  1623 ! !
  1631 ! !
  1624 
  1632 
  1625 !OrderedCollection methodsFor:'private accessing'!
  1633 !OrderedCollection methodsFor:'private accessing'!
  1626 
  1634 
  1627 contentsArray
  1635 contentsArray
       
  1636     "return the orderedCollections underlying contentsArray.
       
  1637      The actual elements are found here starting at firstIndex,
       
  1638      and ending at lastIndex."
       
  1639 
  1628     ^ contentsArray
  1640     ^ contentsArray
  1629 !
  1641 !
  1630 
  1642 
  1631 firstIndex
  1643 firstIndex
       
  1644     "return the index of my first element in my underlying contentsArray.
       
  1645      The actual elements are found starting this index,
       
  1646      and ending at lastIndex."
       
  1647 
  1632     ^ firstIndex
  1648     ^ firstIndex
  1633 ! !
  1649 ! !
  1634 
  1650 
  1635 !OrderedCollection methodsFor:'queries'!
  1651 !OrderedCollection methodsFor:'queries'!
  1636 
  1652 
  1773 ! !
  1789 ! !
  1774 
  1790 
  1775 !OrderedCollection class methodsFor:'documentation'!
  1791 !OrderedCollection class methodsFor:'documentation'!
  1776 
  1792 
  1777 version
  1793 version
  1778     ^ '$Header: /cvs/stx/stx/libbasic/OrderedCollection.st,v 1.70 1999-03-19 20:47:30 cg Exp $'
  1794     ^ '$Header: /cvs/stx/stx/libbasic/OrderedCollection.st,v 1.71 1999-05-08 12:52:11 cg Exp $'
  1779 ! !
  1795 ! !