Skip to content

Commit 24983cf

Browse files
committed
fixup Connections:destroySegment use find
use find to check the segment exists on the cell. Issue was in comparing const iteratior vs segments.end()
1 parent 065b467 commit 24983cf

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

src/htm/algorithms/Connections.cpp

+2-9
Original file line numberDiff line numberDiff line change
@@ -206,18 +206,11 @@ void Connections::destroySegment(const Segment segment) {
206206

207207
CellData &cellData = cells_[segmentData.cell];
208208

209-
const auto segmentOnCell =
210-
std::lower_bound(cellData.segments.cbegin(), cellData.segments.cend(),
211-
segment,
212-
[&](const Segment a, const Segment b) {
213-
return dataForSegment(a).id < dataForSegment(b).id;
214-
});
215-
216-
NTA_ASSERT(segmentOnCell != cellData.segments.end());
209+
const auto segmentOnCell = std::find(cellData.segments.cbegin(), cellData.segments.cend(), segment);
210+
NTA_ASSERT(segmentOnCell != cellData.segments.cend()) << "Segment to be destroyed not found on the cell!";
217211
NTA_ASSERT(*segmentOnCell == segment);
218212

219213
cellData.segments.erase(segmentOnCell);
220-
221214
destroyedSegments_.push_back(segment);
222215
}
223216

src/test/unit/algorithms/TemporalMemoryTest.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1304,7 +1304,7 @@ TEST(TemporalMemoryTest, CreateSegmentDestroyOld) {
13041304
* Hit the maxSegmentsPerCell threshold multiple times. Make sure it works
13051305
* more than once.
13061306
*/
1307-
TEST(ConnectionsTest, ReachSegmentLimitMultipleTimes) {
1307+
TEST(TemporalMemoryTest, ReachSegmentLimitMultipleTimes) {
13081308
TemporalMemory tm(
13091309
/*columnDimensions*/ {32},
13101310
/*cellsPerColumn*/ 1,

0 commit comments

Comments
 (0)