Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CGoGN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thomas Pitiot
CGoGN
Commits
0475e420
Commit
0475e420
authored
Jun 05, 2013
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove dangerous bug of full container
parent
c48c4f10
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
4 deletions
+68
-4
src/Container/attributeContainer.cpp
src/Container/attributeContainer.cpp
+68
-4
No files found.
src/Container/attributeContainer.cpp
View file @
0475e420
...
@@ -307,13 +307,51 @@ void AttributeContainer::compact(std::vector<unsigned int>& mapOldNew)
...
@@ -307,13 +307,51 @@ void AttributeContainer::compact(std::vector<unsigned int>& mapOldNew)
* LINES MANAGEMENT *
* LINES MANAGEMENT *
**************************************/
**************************************/
//unsigned int AttributeContainer::insertLine()
//{
// // if no more rooms
// if (m_tableBlocksWithFree.empty())
// {
// HoleBlockRef* ptr = new HoleBlockRef(); // new block
// m_tableBlocksWithFree.push_back(m_holesBlocks.size()); // add its future position to block_free
// m_holesBlocks.push_back(ptr); // and add it to block table
// for(unsigned int i = 0; i < m_tableAttribs.size(); ++i)
// {
// if (m_tableAttribs[i] != NULL)
// m_tableAttribs[i]->addBlock(); // add a block to every attribute
// }
// }
// // get the first free block index (last in vector)
// unsigned int bf = m_tableBlocksWithFree.back();
// // get the block
// HoleBlockRef* block = m_holesBlocks[bf];
// // add new element in block and compute index
// unsigned int ne = block->newRefElt(m_maxSize);
// unsigned int index = _BLOCKSIZE_ * bf + ne;
// // if no more room in block remove it from free_blocks
// if (block->full())
// m_tableBlocksWithFree.pop_back();
// ++m_size;
//// initLine(index);
// return index;
//}
unsigned
int
AttributeContainer
::
insertLine
()
unsigned
int
AttributeContainer
::
insertLine
()
{
{
// if no more rooms
// if no more rooms
if
(
m_tableBlocksWithFree
.
empty
())
if
(
m_tableBlocksWithFree
.
empty
())
{
{
HoleBlockRef
*
ptr
=
new
HoleBlockRef
();
// new block
HoleBlockRef
*
ptr
=
new
HoleBlockRef
();
// new block
m_tableBlocksWithFree
.
push_back
(
m_holesBlocks
.
size
());
// add its future position to block_free
unsigned
int
numBlock
=
m_holesBlocks
.
size
();
m_tableBlocksWithFree
.
push_back
(
numBlock
);
// add its future position to block_free
m_holesBlocks
.
push_back
(
ptr
);
// and add it to block table
m_holesBlocks
.
push_back
(
ptr
);
// and add it to block table
for
(
unsigned
int
i
=
0
;
i
<
m_tableAttribs
.
size
();
++
i
)
for
(
unsigned
int
i
=
0
;
i
<
m_tableAttribs
.
size
();
++
i
)
...
@@ -321,7 +359,16 @@ unsigned int AttributeContainer::insertLine()
...
@@ -321,7 +359,16 @@ unsigned int AttributeContainer::insertLine()
if
(
m_tableAttribs
[
i
]
!=
NULL
)
if
(
m_tableAttribs
[
i
]
!=
NULL
)
m_tableAttribs
[
i
]
->
addBlock
();
// add a block to every attribute
m_tableAttribs
[
i
]
->
addBlock
();
// add a block to every attribute
}
}
// inc nb of elements
++
m_size
;
// add new element in block and compute index
unsigned
int
ne
=
ptr
->
newRefElt
(
m_maxSize
);
return
_BLOCKSIZE_
*
numBlock
+
ne
;
}
}
// else
// get the first free block index (last in vector)
// get the first free block index (last in vector)
unsigned
int
bf
=
m_tableBlocksWithFree
.
back
();
unsigned
int
bf
=
m_tableBlocksWithFree
.
back
();
...
@@ -332,17 +379,34 @@ unsigned int AttributeContainer::insertLine()
...
@@ -332,17 +379,34 @@ unsigned int AttributeContainer::insertLine()
unsigned
int
ne
=
block
->
newRefElt
(
m_maxSize
);
unsigned
int
ne
=
block
->
newRefElt
(
m_maxSize
);
unsigned
int
index
=
_BLOCKSIZE_
*
bf
+
ne
;
unsigned
int
index
=
_BLOCKSIZE_
*
bf
+
ne
;
if
(
ne
==
_BLOCKSIZE_
-
1
)
{
if
(
bf
==
(
m_holesBlocks
.
size
()
-
1
))
{
// we are filling the last line of capacity
HoleBlockRef
*
ptr
=
new
HoleBlockRef
();
// new block
unsigned
int
numBlock
=
m_holesBlocks
.
size
();
m_tableBlocksWithFree
.
back
()
=
numBlock
;
m_tableBlocksWithFree
.
push_back
(
bf
);
m_holesBlocks
.
push_back
(
ptr
);
for
(
unsigned
int
i
=
0
;
i
<
m_tableAttribs
.
size
();
++
i
)
{
if
(
m_tableAttribs
[
i
]
!=
NULL
)
m_tableAttribs
[
i
]
->
addBlock
();
// add a block to every attribute
}
}
}
// if no more room in block remove it from free_blocks
// if no more room in block remove it from free_blocks
if
(
block
->
full
())
if
(
block
->
full
())
m_tableBlocksWithFree
.
pop_back
();
m_tableBlocksWithFree
.
pop_back
();
++
m_size
;
++
m_size
;
// initLine(index);
return
index
;
return
index
;
}
}
void
AttributeContainer
::
removeLine
(
unsigned
int
index
)
void
AttributeContainer
::
removeLine
(
unsigned
int
index
)
{
{
unsigned
int
bi
=
index
/
_BLOCKSIZE_
;
unsigned
int
bi
=
index
/
_BLOCKSIZE_
;
...
...
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