mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
Core: BiVector, BiArray Create with parameters
This commit is contained in:
parent
fec5bc6a34
commit
143ad0aa3d
7 changed files with 108 additions and 7 deletions
45
autotest/BiCreate/BiCreate.cpp
Normal file
45
autotest/BiCreate/BiCreate.cpp
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
#include <Core/Core.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
struct Foo : Tuple2<int, int> {
|
||||
int c;
|
||||
|
||||
Foo(int a, int b, int c) : Tuple2<int, int>(a, b), c(c) {}
|
||||
};
|
||||
|
||||
CONSOLE_APP_MAIN
|
||||
{
|
||||
StdLogSetup(LOG_COUT|LOG_FILE);
|
||||
|
||||
{
|
||||
BiVector<Tuple2<int, int>> m;
|
||||
|
||||
m.CreateTail(3, 4);
|
||||
m.CreateHead(1, 2);
|
||||
|
||||
DDUMP(m);
|
||||
}
|
||||
|
||||
{
|
||||
BiArray<Tuple2<int, int>> m;
|
||||
|
||||
m.CreateTail(7, 8);
|
||||
m.CreateHead(5, 6);
|
||||
|
||||
DDUMP(m);
|
||||
}
|
||||
|
||||
{
|
||||
BiArray<Tuple2<int, int>> m;
|
||||
|
||||
m.CreateTail<Foo>(11, 12, 13);
|
||||
m.CreateHead(9, 10);
|
||||
|
||||
DDUMP(m);
|
||||
|
||||
DDUMP(((Foo&)m.Tail()).c);
|
||||
}
|
||||
|
||||
CheckLogEtalon();
|
||||
}
|
||||
10
autotest/BiCreate/BiCreate.upp
Normal file
10
autotest/BiCreate/BiCreate.upp
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
uses
|
||||
Core;
|
||||
|
||||
file
|
||||
Etalon.log,
|
||||
BiCreate.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "";
|
||||
|
||||
6
autotest/BiCreate/Etalon.log
Normal file
6
autotest/BiCreate/Etalon.log
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
* C:\upp\out\autotest\CLANGx64.Debug.Debug_Full\BiCreate.exe 16.05.2022 13:32:31, user: cxl
|
||||
|
||||
m = [(1, 2), (3, 4)]
|
||||
m = [(5, 6), (7, 8)]
|
||||
m = [(9, 10), (11, 12)]
|
||||
((Foo&)m.Tail()).c = 13
|
||||
|
|
@ -27,6 +27,10 @@ public:
|
|||
|
||||
T& AddHead() { return *new(AddHead0()) T; }
|
||||
T& AddTail() { return *new(AddTail0()) T; }
|
||||
template <class... Args>
|
||||
T& CreateHead(Args&&... args) { return *new(AddHead0()) T(std::forward<Args>(args)...); }
|
||||
template <class... Args>
|
||||
T& CreateTail(Args&&... args) { return *new(AddTail0()) T(std::forward<Args>(args)...); }
|
||||
void AddHead(const T& x) { new(AddHead0()) T(x); }
|
||||
void AddTail(const T& x) { new(AddTail0()) T(x); }
|
||||
void AddHead(T&& x) { new(AddHead0()) T(pick(x)); }
|
||||
|
|
@ -108,8 +112,14 @@ public:
|
|||
void AddTail(const T& x) { bv.AddTail(new T(x)); }
|
||||
T& AddHead(T *newt) { bv.AddHead(newt); return *newt; }
|
||||
T& AddTail(T *newt) { bv.AddTail(newt); return *newt; }
|
||||
template <class TT> TT& CreateHead() { TT *q = new TT; bv.AddHead(q); return *q; }
|
||||
template <class TT> TT& CreateTail() { TT *q = new TT; bv.AddTail(q); return *q; }
|
||||
template <class... Args>
|
||||
T& CreateHead(Args&&... args) { T *q = new T(std::forward<Args>(args)...); bv.AddHead(q); return *q; }
|
||||
template <class... Args>
|
||||
T& CreateTail(Args&&... args) { T *q = new T(std::forward<Args>(args)...); bv.AddTail(q); return *q; }
|
||||
template <class TT, class... Args>
|
||||
TT& CreateHead(Args&&... args) { TT *q = new TT(std::forward<Args>(args)...); bv.AddHead(q); return *q; }
|
||||
template <class TT, class... Args>
|
||||
TT& CreateTail(Args&&... args) { TT *q = new TT(std::forward<Args>(args)...); bv.AddTail(q); return *q; }
|
||||
T& AddHead(One<T>&& one) { ASSERT(one); return AddHead(one.Detach()); }
|
||||
T& AddTail(One<T>&& one) { ASSERT(one); return AddTail(one.Detach()); }
|
||||
T& Head() { return *(T *) bv.Head(); }
|
||||
|
|
|
|||
|
|
@ -166,14 +166,30 @@ be at position GetCount() `- 1.&]
|
|||
[s7; [*/ Return value]-|Reference to the object `- [* `*newt].&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:Upp`:`:BiArray`:`:CreateHead`(Args`&`&`.`.`.args`):%- [@(0.0.255) template]_<[@(0.0.255) c
|
||||
lass...]_[*@4 Args]>_[*@4 T][@(0.0.255) `&]_[* CreateHead]([*@4 Args][@(0.0.255) `&`&...]_[*@3 a
|
||||
rgs])&]
|
||||
[s2; Creates a new element at the head with [%-*@3 args] constructor
|
||||
parameters.&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:Upp`:`:BiArray`:`:CreateTail`(Args`&`&`.`.`.args`):%- [@(0.0.255) template]_<[@(0.0.255) c
|
||||
lass...]_[*@4 Args]>_[*@4 T][@(0.0.255) `&]_[* CreateTail]([*@4 Args][@(0.0.255) `&`&...]_[*@3 a
|
||||
rgs])&]
|
||||
[s2; Creates a new element at the tail with [%-*@3 args] constructor
|
||||
parameters.&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:Upp`:`:BiArray`:`:CreateHead`(`):%- [@(0.0.255) template]_<[@(0.0.255) class]_[*@4 TT]>
|
||||
_[*@4 TT][@(0.0.255) `&]_[* CreateHead]()&]
|
||||
[s2; Creates a new element of type [%-*@4 TT] at the head.&]
|
||||
_[*@4 TT][@(0.0.255) `&]_[* CreateHead]([*@4 Args][@(0.0.255) `&`&...]_[*@3 args])&]
|
||||
[s2; Creates a new element of type [%-*@4 TT] at the head with [%-*@3 args]
|
||||
constructor parameters.&]
|
||||
[s3;%- &]
|
||||
[s4;%- &]
|
||||
[s5;:Upp`:`:BiArray`:`:CreateTail`(`):%- [@(0.0.255) template]_<[@(0.0.255) class]_[*@4 TT]>
|
||||
_[*@4 TT][@(0.0.255) `&]_[* CreateTail]()&]
|
||||
[s2; Creates a new element of type [%-*@4 TT] at the tail.&]
|
||||
_[*@4 TT][@(0.0.255) `&]_[* CreateTail]([*@4 Args][@(0.0.255) `&`&...]_[*@3 args])&]
|
||||
[s2; Creates a new element of type [%-*@4 TT] at the tail with [%-*@3 args]
|
||||
constructor parameters.&]
|
||||
[s3;%- &]
|
||||
[s4;%- &]
|
||||
[s5;:Upp`:`:BiArray`:`:AddHead`(Upp`:`:One`<T`>`&`&`):%- [*@4 T][@(0.0.255) `&]_[* AddHead](
|
||||
|
|
|
|||
|
|
@ -88,6 +88,20 @@ reference to the newly added default constructed element.&]
|
|||
[s6; Invalidates iterators and references to the BiVector.&]
|
||||
[s3;%- &]
|
||||
[s4;%- &]
|
||||
[s5;:Upp`:`:BiVector`:`:CreateHead`(Args`&`&`.`.`.args`):%- [@(0.0.255) template]_<[@(0.0.255) c
|
||||
lass...]_[*@4 Args]>_[*@4 T][@(0.0.255) `&]_[* CreateHead]([*@4 Args][@(0.0.255) `&`&...]_[*@3 a
|
||||
rgs])&]
|
||||
[s2; Creates a new element at the head with [%-*@3 args] constructor
|
||||
parameters.&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:Upp`:`:BiVector`:`:CreateTail`(Args`&`&`.`.`.args`):%- [@(0.0.255) template]_<[@(0.0.255) c
|
||||
lass...]_[*@4 Args]>_[*@4 T][@(0.0.255) `&]_[* CreateTail]([*@4 Args][@(0.0.255) `&`&...]_[*@3 a
|
||||
rgs])&]
|
||||
[s2; Creates a new element at the tail with [%-*@3 args] constructor
|
||||
parameters.&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:BiVector`:`:AddHead`(const T`&`):%- [@(0.0.255) void]_[* AddHead]([@(0.0.255) const]_[*@4 T
|
||||
][@(0.0.255) `&]_[*@3 x])&]
|
||||
[s2; Adds a new element with the specified value [%-*@3 x ]at the head
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ bool PatchDiff::Open(const char *patch_path, const Vector<String>& target_dirs0)
|
|||
|
||||
failed.Show(failed_count);
|
||||
failed.SetInk(SRed());
|
||||
failed = String() << failed_count << " file(s) failed";
|
||||
failed = String() << failed_count << " failed";
|
||||
|
||||
ShowResult();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue