Mercurial > repos > rhope
changeset 70:1bfcf5f8fa69
Beginning of List implementation
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 16 Jun 2010 04:36:53 +0000 |
parents | d0ce696786cc |
children | c40c3d399133 |
files | list.rhope |
diffstat | 1 files changed, 78 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/list.rhope Wed Jun 16 04:36:53 2010 +0000 @@ -0,0 +1,78 @@ + +Blueprint List Leaf +{ + Buffer +} + +Index@List Leaf[list,index:out,not found] +{ + out, not found <- [[list]Buffer >>]Index[index] +} + +Set@List Leaf[list,index,value:out] +{ + If[[index] < [0]] + { + }{ + If[[index] > [[[list]Buffer >>]Length >>]] + { + makeleft <- Yes + }{ + If[[index] > [7]] + { + makeleft <- Yes + }{ + out <- [list]Buffer <<[ [[list]Buffer >>]Set[index, value] ] + } + } + } + + Val[makeleft] + { + out <- [[[[[[Build[List()] + ]Buffer << [[Array[]]Append[value]] + ]Left << [list] + ]Right << [List[]] + ]Offset << [index] + ]Right Offset <<[[index]+[8i32]] + ]Length << [ [[list]Length]+[1] ] + } +} + +Blueprint List +{ + Buffer + Left + Right + Offset(Int32,Naked) + Right Offset(Int32,Naked) + Length(Int32,Naked) +} + +List[:out(List)] +{ + out <- [Build[List Leaf()]]Buffer <<[Array[]] +} + +Index@List[list,index:out,not found] +{ + If[[index]<[[list]Offset >>]] + { + out, not found <- [[list]Left >>]Index[index] + }{ + If[[index] < [[list]Right Offset >>]] + { + out, not found <- [[list]Buffer >>]Index[[index]-[[list]Offset >>]] + }{ + out, not found <- [[list]Right >>]Index[[index]-[[list]Right Offset >>]] + } + } +} + +Set@List[list,index,val:out,not found] +{ + +} + + +