fixed a bug in stix_oowtoint()
fixed bugs of SemaphoreHeap
This commit is contained in:
		@ -146,6 +146,13 @@
 | 
				
			|||||||
##		self value ifTrue: [ aBlock value. thisContext restart. ].
 | 
					##		self value ifTrue: [ aBlock value. thisContext restart. ].
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						#method whileFalse: aBlock
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							(self value) ifTrue: [^nil].
 | 
				
			||||||
 | 
							aBlock value. 
 | 
				
			||||||
 | 
							self whileFalse: aBlock.
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	#method pc
 | 
						#method pc
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		^ip
 | 
							^ip
 | 
				
			||||||
 | 
				
			|||||||
@ -119,6 +119,11 @@
 | 
				
			|||||||
		^self.size
 | 
							^self.size
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						#method at: anIndex
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							^self.arr at: anIndex.
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	#method insert: aSemaphore
 | 
						#method insert: aSemaphore
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		self.size >= (self.arr size) ifTrue: [
 | 
							self.size >= (self.arr size) ifTrue: [
 | 
				
			||||||
@ -197,27 +202,36 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	#method siftUp: anIndex
 | 
						#method siftUp: anIndex
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		| pindex cindex par cur |
 | 
							| pindex cindex par item stop |
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		anIndex <= 1 ifTrue: [ ^anIndex ].
 | 
							(anIndex <= 1) ifTrue: [ ^anIndex ].
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		cindex := anIndex.
 | 
							pindex := anIndex.
 | 
				
			||||||
		pindex := self parentIndex: anIndex.
 | 
							item := self.arr at: anIndex.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		par := self.arr at: pindex.
 | 
							stop := false.
 | 
				
			||||||
		cur := self.arr at: cindex.
 | 
							[ stop ] whileFalse: [
 | 
				
			||||||
 | 
					 | 
				
			||||||
		[ cur youngerThan: par ] whileTrue: [
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
			cindex := pindex.
 | 
								cindex := pindex.
 | 
				
			||||||
			pindex := self parentIndex: pindex.
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
			par := self.arr at: pindex.
 | 
								(cindex > 1)
 | 
				
			||||||
			cur := self.arr at: cindex.
 | 
									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.
 | 
							self.arr at: cindex put: item.
 | 
				
			||||||
		cur heapIndex: cindex.
 | 
							item heapIndex: cindex.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		^cindex
 | 
							^cindex
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@ -226,8 +240,7 @@
 | 
				
			|||||||
	{
 | 
						{
 | 
				
			||||||
		| base capa cindex item |
 | 
							| base capa cindex item |
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							base := (self.size quo: 2) + 1.
 | 
				
			||||||
		base := self.size quo: 2.
 | 
					 | 
				
			||||||
		(anIndex > base) ifTrue: [^anIndex].
 | 
							(anIndex > base) ifTrue: [^anIndex].
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		cindex := anIndex.
 | 
							cindex := anIndex.
 | 
				
			||||||
 | 
				
			|||||||
@ -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)
 | 
					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);
 | 
							return STIX_SMOOI_TO_OOP(w);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user