Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
56bc686c
Kaydet (Commit)
56bc686c
authored
Eki 08, 2015
tarafından
Miklos Vajna
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
sot: prefix members of StgAvlNode
Change-Id: Ie6de63b524b99246be3d6d5d6e997c7abda675ad
üst
0df69aa1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
115 additions
and
115 deletions
+115
-115
stgavl.cxx
sot/source/sdstor/stgavl.cxx
+87
-87
stgavl.hxx
sot/source/sdstor/stgavl.hxx
+3
-3
stgdir.cxx
sot/source/sdstor/stgdir.cxx
+25
-25
No files found.
sot/source/sdstor/stgavl.cxx
Dosyayı görüntüle @
56bc686c
...
...
@@ -23,14 +23,14 @@
StgAvlNode
::
StgAvlNode
()
{
pLeft
=
pRight
=
NULL
;
nBalance
=
nId
=
0
;
m_pLeft
=
m_
pRight
=
NULL
;
m_nBalance
=
m_
nId
=
0
;
}
StgAvlNode
::~
StgAvlNode
()
{
delete
pLeft
;
delete
pRight
;
delete
m_
pLeft
;
delete
m_
pRight
;
}
StgAvlNode
*
StgAvlNode
::
Find
(
StgAvlNode
*
pFind
)
...
...
@@ -43,7 +43,7 @@ StgAvlNode* StgAvlNode::Find( StgAvlNode* pFind )
short
nRes
=
p
->
Compare
(
pFind
);
if
(
!
nRes
)
return
p
;
else
p
=
(
nRes
<
0
)
?
p
->
pLeft
:
p
->
pRight
;
else
p
=
(
nRes
<
0
)
?
p
->
m_pLeft
:
p
->
m_
pRight
;
}
}
return
NULL
;
...
...
@@ -69,14 +69,14 @@ short StgAvlNode::Locate
while
(
pCur
!=
NULL
)
{
// check for pPivot
if
(
pCur
->
nBalance
!=
0
)
if
(
pCur
->
m_
nBalance
!=
0
)
*
pPivot
=
pCur
,
*
pParent
=
*
pPrev
;
// save pPrev location and see what direction to go
*
pPrev
=
pCur
;
nRes
=
pCur
->
Compare
(
pFind
);
if
(
nRes
==
0
)
break
;
else
pCur
=
(
nRes
<
0
)
?
pCur
->
pLeft
:
pCur
->
pRight
;
else
pCur
=
(
nRes
<
0
)
?
pCur
->
m_pLeft
:
pCur
->
m_
pRight
;
}
}
...
...
@@ -93,37 +93,37 @@ short StgAvlNode::Adjust( StgAvlNode** pHeavy, StgAvlNode* pNew )
// no traversing
OSL_ENSURE
(
pHeavy
&&
pNew
,
"The pointers is not allowed to be NULL!"
);
if
(
pCur
==
pNew
||
!
pNew
)
return
nBalance
;
return
m_
nBalance
;
short
nRes
=
Compare
(
pNew
);
if
(
nRes
>
0
)
{
*
pHeavy
=
pCur
=
pRight
;
*
pHeavy
=
pCur
=
m_
pRight
;
nDelta
=
-
1
;
}
else
{
*
pHeavy
=
pCur
=
pLeft
;
*
pHeavy
=
pCur
=
m_
pLeft
;
nDelta
=
1
;
}
nBalance
=
0
;
m_
nBalance
=
0
;
while
(
pCur
!=
pNew
)
{
nRes
=
pCur
->
Compare
(
pNew
);
if
(
nRes
>
0
)
{
// height of right increases by 1
pCur
->
nBalance
=
-
1
;
pCur
=
pCur
->
pRight
;
pCur
->
m_
nBalance
=
-
1
;
pCur
=
pCur
->
m_
pRight
;
}
else
{
// height of left increases by 1
pCur
->
nBalance
=
1
;
pCur
=
pCur
->
pLeft
;
pCur
->
m_
nBalance
=
1
;
pCur
=
pCur
->
m_
pLeft
;
}
}
nBalance
=
nBalance
+
nDelta
;
m_nBalance
=
m_
nBalance
+
nDelta
;
return
nDelta
;
}
...
...
@@ -131,11 +131,11 @@ short StgAvlNode::Adjust( StgAvlNode** pHeavy, StgAvlNode* pNew )
StgAvlNode
*
StgAvlNode
::
RotLL
()
{
assert
(
pLeft
&&
"The pointer is not allowed to be NULL!"
);
StgAvlNode
*
pHeavy
=
pLeft
;
pLeft
=
pHeavy
->
pRight
;
pHeavy
->
pRight
=
this
;
pHeavy
->
nBalance
=
nBalance
=
0
;
assert
(
m_
pLeft
&&
"The pointer is not allowed to be NULL!"
);
StgAvlNode
*
pHeavy
=
m_
pLeft
;
m_pLeft
=
pHeavy
->
m_
pRight
;
pHeavy
->
m_
pRight
=
this
;
pHeavy
->
m_nBalance
=
m_
nBalance
=
0
;
return
pHeavy
;
}
...
...
@@ -143,71 +143,71 @@ StgAvlNode* StgAvlNode::RotLL()
StgAvlNode
*
StgAvlNode
::
RotLR
()
{
assert
(
pLeft
&&
pLeft
->
pRight
&&
"The pointer is not allowed to be NULL!"
);
StgAvlNode
*
pHeavy
=
pLeft
;
StgAvlNode
*
pNewRoot
=
pHeavy
->
pRight
;
assert
(
m_pLeft
&&
m_pLeft
->
m_
pRight
&&
"The pointer is not allowed to be NULL!"
);
StgAvlNode
*
pHeavy
=
m_
pLeft
;
StgAvlNode
*
pNewRoot
=
pHeavy
->
m_
pRight
;
pHeavy
->
pRight
=
pNewRoot
->
pLeft
;
pLeft
=
pNewRoot
->
pRight
;
pNewRoot
->
pLeft
=
pHeavy
;
pNewRoot
->
pRight
=
this
;
pHeavy
->
m_pRight
=
pNewRoot
->
m_
pLeft
;
m_pLeft
=
pNewRoot
->
m_
pRight
;
pNewRoot
->
m_
pLeft
=
pHeavy
;
pNewRoot
->
m_
pRight
=
this
;
switch
(
pNewRoot
->
nBalance
)
switch
(
pNewRoot
->
m_
nBalance
)
{
case
1
:
// LR( b )
nBalance
=
-
1
;
pHeavy
->
nBalance
=
0
;
m_
nBalance
=
-
1
;
pHeavy
->
m_
nBalance
=
0
;
break
;
case
-
1
:
// LR( c )
pHeavy
->
nBalance
=
1
;
nBalance
=
0
;
pHeavy
->
m_
nBalance
=
1
;
m_
nBalance
=
0
;
break
;
case
0
:
// LR( a )
nBalance
=
0
;
pHeavy
->
nBalance
=
0
;
m_
nBalance
=
0
;
pHeavy
->
m_
nBalance
=
0
;
break
;
}
pNewRoot
->
nBalance
=
0
;
pNewRoot
->
m_
nBalance
=
0
;
return
pNewRoot
;
}
// perform RR rotation and return new root
StgAvlNode
*
StgAvlNode
::
RotRR
()
{
assert
(
pRight
&&
"The pointer is not allowed to be NULL!"
);
StgAvlNode
*
pHeavy
=
pRight
;
pRight
=
pHeavy
->
pLeft
;
pHeavy
->
pLeft
=
this
;
nBalance
=
pHeavy
->
nBalance
=
0
;
assert
(
m_
pRight
&&
"The pointer is not allowed to be NULL!"
);
StgAvlNode
*
pHeavy
=
m_
pRight
;
m_pRight
=
pHeavy
->
m_
pLeft
;
pHeavy
->
m_
pLeft
=
this
;
m_nBalance
=
pHeavy
->
m_
nBalance
=
0
;
return
pHeavy
;
}
// perform the RL rotation and return the new root
StgAvlNode
*
StgAvlNode
::
RotRL
()
{
assert
(
pRight
&&
pRight
->
pLeft
&&
"The pointer is not allowed to be NULL!"
);
StgAvlNode
*
pHeavy
=
pRight
;
StgAvlNode
*
pNewRoot
=
pHeavy
->
pLeft
;
pHeavy
->
pLeft
=
pNewRoot
->
pRight
;
pRight
=
pNewRoot
->
pLeft
;
pNewRoot
->
pRight
=
pHeavy
;
pNewRoot
->
pLeft
=
this
;
switch
(
pNewRoot
->
nBalance
)
assert
(
m_pRight
&&
m_pRight
->
m_
pLeft
&&
"The pointer is not allowed to be NULL!"
);
StgAvlNode
*
pHeavy
=
m_
pRight
;
StgAvlNode
*
pNewRoot
=
pHeavy
->
m_
pLeft
;
pHeavy
->
m_pLeft
=
pNewRoot
->
m_
pRight
;
m_pRight
=
pNewRoot
->
m_
pLeft
;
pNewRoot
->
m_
pRight
=
pHeavy
;
pNewRoot
->
m_
pLeft
=
this
;
switch
(
pNewRoot
->
m_
nBalance
)
{
case
-
1
:
// RL( b )
nBalance
=
1
;
pHeavy
->
nBalance
=
0
;
m_
nBalance
=
1
;
pHeavy
->
m_
nBalance
=
0
;
break
;
case
1
:
// RL( c )
pHeavy
->
nBalance
=
-
1
;
nBalance
=
0
;
pHeavy
->
m_
nBalance
=
-
1
;
m_
nBalance
=
0
;
break
;
case
0
:
// RL( a )
nBalance
=
0
;
pHeavy
->
nBalance
=
0
;
m_
nBalance
=
0
;
pHeavy
->
m_
nBalance
=
0
;
break
;
}
pNewRoot
->
nBalance
=
0
;
pNewRoot
->
m_
nBalance
=
0
;
return
pNewRoot
;
}
...
...
@@ -222,13 +222,13 @@ StgAvlNode* StgAvlNode::Rem( StgAvlNode** p, StgAvlNode* pDel, bool bPtrs )
if
(
!
nRes
)
{
// Element found: remove
if
(
!
pCur
->
pRight
)
if
(
!
pCur
->
m_
pRight
)
{
*
p
=
pCur
->
pLeft
;
pCur
->
pLeft
=
NULL
;
*
p
=
pCur
->
m_pLeft
;
pCur
->
m_
pLeft
=
NULL
;
}
else
if
(
!
pCur
->
pLeft
)
else
if
(
!
pCur
->
m_
pLeft
)
{
*
p
=
pCur
->
pRight
;
pCur
->
pRight
=
NULL
;
*
p
=
pCur
->
m_pRight
;
pCur
->
m_
pRight
=
NULL
;
}
else
{
...
...
@@ -238,28 +238,28 @@ StgAvlNode* StgAvlNode::Rem( StgAvlNode** p, StgAvlNode* pDel, bool bPtrs )
// this element with the element found.
StgAvlNode
*
last
=
pCur
;
StgAvlNode
*
l
;
for
(
l
=
pCur
->
pLeft
;
l
->
pRight
;
last
=
l
,
l
=
l
->
pRight
)
{}
for
(
l
=
pCur
->
m_
pLeft
;
l
->
m_pRight
;
last
=
l
,
l
=
l
->
m_
pRight
)
{}
// remove the element from chain
if
(
l
==
last
->
pRight
)
last
->
pRight
=
l
->
pLeft
;
if
(
l
==
last
->
m_
pRight
)
last
->
m_pRight
=
l
->
m_
pLeft
;
else
last
->
pLeft
=
l
->
pLeft
;
last
->
m_pLeft
=
l
->
m_
pLeft
;
// perform the replacement
l
->
pLeft
=
pCur
->
pLeft
;
l
->
pRight
=
pCur
->
pRight
;
l
->
m_pLeft
=
pCur
->
m_
pLeft
;
l
->
m_pRight
=
pCur
->
m_
pRight
;
*
p
=
l
;
// delete the element
pCur
->
pLeft
=
pCur
->
pRight
=
NULL
;
pCur
->
m_pLeft
=
pCur
->
m_
pRight
=
NULL
;
}
return
pCur
;
}
else
{
if
(
nRes
<
0
)
return
Rem
(
&
pCur
->
pLeft
,
pDel
,
bPtrs
);
return
Rem
(
&
pCur
->
m_
pLeft
,
pDel
,
bPtrs
);
else
return
Rem
(
&
pCur
->
pRight
,
pDel
,
bPtrs
);
return
Rem
(
&
pCur
->
m_
pRight
,
pDel
,
bPtrs
);
}
}
return
NULL
;
...
...
@@ -269,11 +269,11 @@ StgAvlNode* StgAvlNode::Rem( StgAvlNode** p, StgAvlNode* pDel, bool bPtrs )
void
StgAvlNode
::
StgEnum
(
short
&
n
)
{
if
(
pLeft
)
pLeft
->
StgEnum
(
n
);
nId
=
n
++
;
if
(
pRight
)
pRight
->
StgEnum
(
n
);
if
(
m_
pLeft
)
m_
pLeft
->
StgEnum
(
n
);
m_
nId
=
n
++
;
if
(
m_
pRight
)
m_
pRight
->
StgEnum
(
n
);
}
// Add node to AVL tree.
...
...
@@ -300,32 +300,32 @@ bool StgAvlNode::Insert( StgAvlNode** pRoot, StgAvlNode* pIns )
// add new node
if
(
nRes
<
0
)
pPrev
->
pLeft
=
pIns
;
pPrev
->
m_
pLeft
=
pIns
;
else
pPrev
->
pRight
=
pIns
;
pPrev
->
m_
pRight
=
pIns
;
// rebalance tree
short
nDelta
=
pPivot
->
Adjust
(
&
pHeavy
,
pIns
);
if
(
pPivot
->
nBalance
>=
2
||
pPivot
->
nBalance
<=
-
2
)
if
(
pPivot
->
m_nBalance
>=
2
||
pPivot
->
m_
nBalance
<=
-
2
)
{
pHeavy
=
(
nDelta
<
0
)
?
pPivot
->
pRight
:
pPivot
->
pLeft
;
pHeavy
=
(
nDelta
<
0
)
?
pPivot
->
m_pRight
:
pPivot
->
m_
pLeft
;
// left imbalance
if
(
nDelta
>
0
)
if
(
pHeavy
->
nBalance
==
1
)
if
(
pHeavy
->
m_
nBalance
==
1
)
pNewRoot
=
pPivot
->
RotLL
();
else
pNewRoot
=
pPivot
->
RotLR
();
// right imbalance
else
if
(
pHeavy
->
nBalance
==
-
1
)
else
if
(
pHeavy
->
m_
nBalance
==
-
1
)
pNewRoot
=
pPivot
->
RotRR
();
else
pNewRoot
=
pPivot
->
RotRL
();
// relink balanced subtree
if
(
pParent
==
NULL
)
*
pRoot
=
pNewRoot
;
else
if
(
pPivot
==
pParent
->
pLeft
)
pParent
->
pLeft
=
pNewRoot
;
else
if
(
pPivot
==
pParent
->
pRight
)
pParent
->
pRight
=
pNewRoot
;
else
if
(
pPivot
==
pParent
->
m_
pLeft
)
pParent
->
m_
pLeft
=
pNewRoot
;
else
if
(
pPivot
==
pParent
->
m_
pRight
)
pParent
->
m_
pRight
=
pNewRoot
;
}
return
true
;
}
...
...
@@ -385,9 +385,9 @@ StgAvlNode* StgAvlIterator::Find( short n )
StgAvlNode
*
p
=
m_pRoot
;
while
(
p
)
{
if
(
n
==
p
->
nId
)
if
(
n
==
p
->
m_
nId
)
break
;
else
p
=
(
n
<
p
->
nId
)
?
p
->
pLeft
:
p
->
pRight
;
else
p
=
(
n
<
p
->
m_nId
)
?
p
->
m_pLeft
:
p
->
m_
pRight
;
}
return
p
;
}
...
...
sot/source/sdstor/stgavl.hxx
Dosyayı görüntüle @
56bc686c
...
...
@@ -36,9 +36,9 @@ private:
void
StgEnum
(
short
&
);
static
StgAvlNode
*
Rem
(
StgAvlNode
**
,
StgAvlNode
*
,
bool
);
protected
:
short
nId
;
// iterator ID
short
nBalance
;
// indicates tree balance
StgAvlNode
*
pLeft
,
*
pRight
;
// leaves
short
m_
nId
;
// iterator ID
short
m_
nBalance
;
// indicates tree balance
StgAvlNode
*
m_pLeft
,
*
m_
pRight
;
// leaves
StgAvlNode
();
public
:
virtual
~
StgAvlNode
();
...
...
sot/source/sdstor/stgdir.cxx
Dosyayı görüntüle @
56bc686c
...
...
@@ -116,15 +116,15 @@ void StgDirEntry::Enum( sal_Int32& n )
{
sal_Int32
nLeft
=
STG_FREE
,
nRight
=
STG_FREE
,
nDown
=
STG_FREE
;
m_nEntry
=
n
++
;
if
(
pLeft
)
if
(
m_
pLeft
)
{
static_cast
<
StgDirEntry
*>
(
pLeft
)
->
Enum
(
n
);
nLeft
=
static_cast
<
StgDirEntry
*>
(
pLeft
)
->
m_nEntry
;
static_cast
<
StgDirEntry
*>
(
m_
pLeft
)
->
Enum
(
n
);
nLeft
=
static_cast
<
StgDirEntry
*>
(
m_
pLeft
)
->
m_nEntry
;
}
if
(
pRight
)
if
(
m_
pRight
)
{
static_cast
<
StgDirEntry
*>
(
pRight
)
->
Enum
(
n
);
nRight
=
static_cast
<
StgDirEntry
*>
(
pRight
)
->
m_nEntry
;
static_cast
<
StgDirEntry
*>
(
m_
pRight
)
->
Enum
(
n
);
nRight
=
static_cast
<
StgDirEntry
*>
(
m_
pRight
)
->
m_nEntry
;
}
if
(
m_pDown
)
{
...
...
@@ -140,10 +140,10 @@ void StgDirEntry::Enum( sal_Int32& n )
void
StgDirEntry
::
DelTemp
(
bool
bForce
)
{
if
(
pLeft
)
static_cast
<
StgDirEntry
*>
(
pLeft
)
->
DelTemp
(
false
);
if
(
pRight
)
static_cast
<
StgDirEntry
*>
(
pRight
)
->
DelTemp
(
false
);
if
(
m_
pLeft
)
static_cast
<
StgDirEntry
*>
(
m_
pLeft
)
->
DelTemp
(
false
);
if
(
m_
pRight
)
static_cast
<
StgDirEntry
*>
(
m_
pRight
)
->
DelTemp
(
false
);
if
(
m_pDown
)
{
// If the storage is dead, of course all elements are dead, too
...
...
@@ -162,7 +162,7 @@ void StgDirEntry::DelTemp( bool bForce )
StgAvlNode
::
Remove
(
reinterpret_cast
<
StgAvlNode
**>
(
&
m_pUp
->
m_pDown
),
this
,
bDel
);
if
(
!
bDel
)
{
pLeft
=
pRight
=
m_pDown
=
0
;
m_pLeft
=
m_
pRight
=
m_pDown
=
0
;
m_bInvalid
=
m_bZombie
=
true
;
}
}
...
...
@@ -178,11 +178,11 @@ bool StgDirEntry::Store( StgDirStrm& rStrm )
return
false
;
// Do not store the current (maybe not committed) entry
m_aSave
.
Store
(
pEntry
);
if
(
pLeft
)
if
(
!
static_cast
<
StgDirEntry
*>
(
pLeft
)
->
Store
(
rStrm
)
)
if
(
m_
pLeft
)
if
(
!
static_cast
<
StgDirEntry
*>
(
m_
pLeft
)
->
Store
(
rStrm
)
)
return
false
;
if
(
pRight
)
if
(
!
static_cast
<
StgDirEntry
*>
(
pRight
)
->
Store
(
rStrm
)
)
if
(
m_
pRight
)
if
(
!
static_cast
<
StgDirEntry
*>
(
m_
pRight
)
->
Store
(
rStrm
)
)
return
false
;
if
(
m_pDown
)
if
(
!
m_pDown
->
Store
(
rStrm
)
)
...
...
@@ -218,11 +218,11 @@ bool StgDirEntry::StoreStreams( StgIo& rIo )
{
if
(
!
StoreStream
(
rIo
)
)
return
false
;
if
(
pLeft
)
if
(
!
static_cast
<
StgDirEntry
*>
(
pLeft
)
->
StoreStreams
(
rIo
)
)
if
(
m_
pLeft
)
if
(
!
static_cast
<
StgDirEntry
*>
(
m_
pLeft
)
->
StoreStreams
(
rIo
)
)
return
false
;
if
(
pRight
)
if
(
!
static_cast
<
StgDirEntry
*>
(
pRight
)
->
StoreStreams
(
rIo
)
)
if
(
m_
pRight
)
if
(
!
static_cast
<
StgDirEntry
*>
(
m_
pRight
)
->
StoreStreams
(
rIo
)
)
return
false
;
if
(
m_pDown
)
if
(
!
m_pDown
->
StoreStreams
(
rIo
)
)
...
...
@@ -235,10 +235,10 @@ bool StgDirEntry::StoreStreams( StgIo& rIo )
void
StgDirEntry
::
RevertAll
()
{
m_aEntry
=
m_aSave
;
if
(
pLeft
)
static_cast
<
StgDirEntry
*>
(
pLeft
)
->
RevertAll
();
if
(
pRight
)
static_cast
<
StgDirEntry
*>
(
pRight
)
->
RevertAll
();
if
(
m_
pLeft
)
static_cast
<
StgDirEntry
*>
(
m_
pLeft
)
->
RevertAll
();
if
(
m_
pRight
)
static_cast
<
StgDirEntry
*>
(
m_
pRight
)
->
RevertAll
();
if
(
m_pDown
)
m_pDown
->
RevertAll
();
}
...
...
@@ -249,9 +249,9 @@ bool StgDirEntry::IsDirty()
{
if
(
m_bDirty
||
m_bInvalid
)
return
true
;
if
(
pLeft
&&
static_cast
<
StgDirEntry
*>
(
pLeft
)
->
IsDirty
()
)
if
(
m_pLeft
&&
static_cast
<
StgDirEntry
*>
(
m_
pLeft
)
->
IsDirty
()
)
return
true
;
if
(
pRight
&&
static_cast
<
StgDirEntry
*>
(
pRight
)
->
IsDirty
()
)
if
(
m_pRight
&&
static_cast
<
StgDirEntry
*>
(
m_
pRight
)
->
IsDirty
()
)
return
true
;
if
(
m_pDown
&&
m_pDown
->
IsDirty
()
)
return
true
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment