Mercurial > repos > rhope
view list.rhope @ 70:1bfcf5f8fa69
Beginning of List implementation
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 16 Jun 2010 04:36:53 +0000 |
parents | |
children | 0083b2f7b3c7 |
line wrap: on
line source
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] { }