MCPcopy Create free account
hub / github.com/cxasm/notepad-- / SetValueAt

Method SetValueAt

src/qscint/scintilla/src/SparseVector.h:63–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61 }
62 template <typename ParamType>
63 void SetValueAt(Sci::Position position, ParamType &&value) {
64 assert(position < Length());
65 const Sci::Position partition = starts->PartitionFromPosition(position);
66 const Sci::Position startPartition = starts->PositionFromPartition(partition);
67 if (value == T()) {
68 // Setting the empty value is equivalent to deleting the position
69 if (position == 0) {
70 ClearValue(partition);
71 } else if (position == startPartition) {
72 // Currently an element at this position, so remove
73 ClearValue(partition);
74 starts->RemovePartition(partition);
75 values->Delete(partition);
76 }
77 // Else element remains empty
78 } else {
79 if (position == startPartition) {
80 // Already a value at this position, so replace
81 ClearValue(partition);
82 values->SetValueAt(partition, std::forward<ParamType>(value));
83 } else {
84 // Insert a new element
85 starts->InsertPartition(partition + 1, position);
86 values->Insert(partition + 1, std::forward<ParamType>(value));
87 }
88 }
89 }
90 void InsertSpace(Sci::Position position, Sci::Position insertLength) {
91 assert(position <= Length()); // Only operation that works at end.
92 const Sci::Position partition = starts->PartitionFromPosition(position);

Callers 1

ClearValueMethod · 0.45

Calls 7

TFunction · 0.85
PartitionFromPositionMethod · 0.80
PositionFromPartitionMethod · 0.80
RemovePartitionMethod · 0.80
InsertPartitionMethod · 0.80
DeleteMethod · 0.45
InsertMethod · 0.45

Tested by

no test coverage detected