mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
Core: Bits optimized, CtrlLib: ArrayCtrl::WhenColumnSort
git-svn-id: svn://ultimatepp.org/upp/trunk@11029 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
647b4ee789
commit
ce7186cd36
6 changed files with 36 additions and 30 deletions
|
|
@ -331,32 +331,4 @@ unsigned GetHashValue0(const double& d)
|
|||
return memhash(&d, sizeof(double));
|
||||
}
|
||||
|
||||
void Bits::Clear()
|
||||
{
|
||||
if(bp)
|
||||
delete[] bp;
|
||||
alloc = 0;
|
||||
bp = NULL;
|
||||
}
|
||||
|
||||
void Bits::Set(int i, bool b)
|
||||
{
|
||||
ASSERT(i >= 0 && alloc >= 0);
|
||||
int q = i >> 5;
|
||||
if(q >= alloc) {
|
||||
int nalloc = 4 * q / 3 + 1;
|
||||
dword *nbp = new dword[nalloc];
|
||||
if(bp) {
|
||||
Copy(nbp, bp, bp + alloc);
|
||||
delete[] bp;
|
||||
}
|
||||
Fill(nbp + alloc, nbp + nalloc, (dword)0);
|
||||
bp = nbp;
|
||||
alloc = nalloc;
|
||||
}
|
||||
i &= 31;
|
||||
ASSERT(q < alloc);
|
||||
bp[q] = (bp[q] & ~(1 << i)) | (b << i);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -117,10 +117,13 @@ public:
|
|||
class Bits : Moveable<Bits> {
|
||||
int alloc;
|
||||
dword *bp;
|
||||
|
||||
void Expand(int q);
|
||||
|
||||
public:
|
||||
void Clear();
|
||||
void Set(int i, bool b = true);
|
||||
void Set(int i, bool b = true) { ASSERT(i >= 0 && alloc >= 0); int q = i >> 5;
|
||||
if(q >= alloc) Expand(q); i &= 31; bp[q] = (bp[q] & ~(1 << i)) | (b << i); }
|
||||
bool Get(int i) const { ASSERT(i >= 0 && alloc >= 0); int q = i >> 5;
|
||||
return q < alloc ? bp[q] & (1 << (i & 31)) : false; }
|
||||
bool operator[](int i) const { return Get(i); }
|
||||
|
|
|
|||
|
|
@ -83,4 +83,26 @@ thread__ int invector_cache_blki_;
|
|||
thread__ int invector_cache_offset_;
|
||||
thread__ int invector_cache_end_;
|
||||
|
||||
|
||||
void Bits::Clear()
|
||||
{
|
||||
if(bp)
|
||||
delete[] bp;
|
||||
alloc = 0;
|
||||
bp = NULL;
|
||||
}
|
||||
|
||||
void Bits::Expand(int q)
|
||||
{
|
||||
int nalloc = 4 * q / 3 + 1;
|
||||
dword *nbp = new dword[nalloc];
|
||||
if(bp) {
|
||||
Copy(nbp, bp, bp + alloc);
|
||||
delete[] bp;
|
||||
}
|
||||
Fill(nbp + alloc, nbp + nalloc, (dword)0);
|
||||
bp = nbp;
|
||||
alloc = nalloc;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2558,6 +2558,7 @@ void ArrayCtrl::DoColumnSort()
|
|||
ColumnSort(sortcolumn, cs);
|
||||
}
|
||||
}
|
||||
WhenColumnSorted();
|
||||
}
|
||||
|
||||
ArrayCtrl& ArrayCtrl::AllSorting()
|
||||
|
|
|
|||
|
|
@ -357,6 +357,7 @@ public:
|
|||
Event<> WhenCtrlsAction;
|
||||
Event<> WhenScroll;
|
||||
Event<> WhenHeaderLayout;
|
||||
Event<> WhenColumnSorted;
|
||||
|
||||
Event<int, bool&> WhenLineEnabled;
|
||||
Event<int, bool&> WhenLineVisible;
|
||||
|
|
|
|||
|
|
@ -2619,6 +2619,13 @@ in the cell editors and react to specific situations accordingly.&]
|
|||
[s5;:ArrayCtrl`:`:WhenHeaderLayout: [_^Callback^ Callback]_[* WhenHeaderLayout]&]
|
||||
[s2; Called when header changes.&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:Upp`:`:ArrayCtrl`:`:WhenColumnSorted:%- [_^Upp`:`:Event^ Event]<>_[* WhenColumnSorte
|
||||
d]&]
|
||||
[s2; Invoked at the end of DoColumnSort. This allows to react to
|
||||
user sorting ArrayCtrl by clicking on column header marked as
|
||||
Sorting.&]
|
||||
[s3;%- &]
|
||||
[s4; &]
|
||||
[s5;:ArrayCtrl`:`:WhenLineEnabled: [_^Callback2^ Callback2]<[@(0.0.255) int],
|
||||
[@(0.0.255) bool`&]>_[* WhenLineEnabled]&]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue