fixed a bug in stix_oowtoint()

fixed bugs of SemaphoreHeap
This commit is contained in:
hyunghwan.chung 2016-03-16 10:13:03 +00:00
parent fabc9afee8
commit 117473f638
3 changed files with 38 additions and 16 deletions

View File

@ -146,6 +146,13 @@
## self value ifTrue: [ aBlock value. thisContext restart. ].
}
#method whileFalse: aBlock
{
(self value) ifTrue: [^nil].
aBlock value.
self whileFalse: aBlock.
}
#method pc
{
^ip

View File

@ -119,6 +119,11 @@
^self.size
}
#method at: anIndex
{
^self.arr at: anIndex.
}
#method insert: aSemaphore
{
self.size >= (self.arr size) ifTrue: [
@ -197,27 +202,36 @@
#method siftUp: anIndex
{
| pindex cindex par cur |
| pindex cindex par item stop |
anIndex <= 1 ifTrue: [ ^anIndex ].
(anIndex <= 1) ifTrue: [ ^anIndex ].
cindex := anIndex.
pindex := self parentIndex: anIndex.
pindex := anIndex.
item := self.arr at: anIndex.
par := self.arr at: pindex.
cur := self.arr at: cindex.
[ cur youngerThan: par ] whileTrue: [
stop := false.
[ stop ] whileFalse: [
cindex := pindex.
pindex := self parentIndex: pindex.
par := self.arr at: pindex.
cur := self.arr at: cindex.
(cindex > 1)
ifTrue: [
pindex := self parentIndex: cindex.
par := self.arr at: pindex.
(item youngerThan: par)
ifTrue: [
## move the parent down
self.arr at: cindex put: par.
par heapIndex: cindex.
]
ifFalse: [ stop := true ].
]
ifFalse: [ stop := true ].
].
self.arr at: cindex put: cur.
cur heapIndex: cindex.
self.arr at: cindex put: item.
item heapIndex: cindex.
^cindex
}
@ -226,8 +240,7 @@
{
| base capa cindex item |
base := self.size quo: 2.
base := (self.size quo: 2) + 1.
(anIndex > base) ifTrue: [^anIndex].
cindex := anIndex.

View File

@ -439,7 +439,9 @@ static STIX_INLINE stix_oop_t make_bigint_with_intmax (stix_t* stix, stix_intmax
stix_oop_t stix_oowtoint (stix_t* stix, stix_oow_t w)
{
if (STIX_IN_SMOOI_RANGE(w))
STIX_ASSERT (STIX_TYPE_IS_UNSIGNED(stix_oow_t));
/*if (STIX_IN_SMOOI_RANGE(w))*/
if (w <= STIX_SMOOI_MAX)
{
return STIX_SMOOI_TO_OOP(w);
}