On Tuesday, 15 November 2022 at 23:27:07 UTC, Siarhei Siamashka
wrote:
For doing a fast insert into an already sorted array (and
avoiding duplicated values) it's probably better to do
something like this:
```D
bool fast_insert_into_a_sorted_array(alias less = "a < b",
T)(ref T[] a, T value)
On Tuesday, 15 November 2022 at 20:09:40 UTC, Per Nordlöw wrote:
I wanted a sorted array because I want to include it in a
benchmark suite and study it's time and space complexity. No
application yet.
For doing a fast insert into an already sorted array (and
avoiding duplicated values) it's p
On Tuesday, 15 November 2022 at 22:32:56 UTC, Per Nordlöw wrote:
Still, does anybody understand why the line
https://github.com/nordlow/phobos-next/blob/master/src/nxt/sorted.d#L52 fails to compile
Maybe add two typeof arguments?
```D
completeSort!(less, ss, typeof(_source),
typeof(_raw))(_s
On Tuesday, 15 November 2022 at 22:15:36 UTC, Per Nordlöw wrote:
On Tuesday, 15 November 2022 at 21:03:24 UTC, Per Nordlöw wrote:
This is what I have so far.
Found some issues but still cannot instantiate my solution at
https://github.com/nordlow/phobos-next/blob/master/src/nxt/sorted.d#L15
On Tuesday, 15 November 2022 at 21:03:24 UTC, Per Nordlöw wrote:
This is what I have so far.
Found some issues but still cannot instantiate my solution at
https://github.com/nordlow/phobos-next/blob/master/src/nxt/sorted.d#L15
when I uncomment the line containing
```d
// TODO: completeSort!(
This is what I have so far.
```d
import std.algorithm.mutation : SwapStrategy;
/** Wrapper container around array (slice) or array-like
(container) `A`.
*
* See_Also: https://en.wikipedia.org/wiki/Sorted_array
*/
struct Sorted(A, alias less = "a < b", SwapStrategy ss =
SwapStrategy.unstabl
On Monday, 14 November 2022 at 00:29:40 UTC, Tejas wrote:
He said on Discord he want contiguous data structure, rbtree
allocates too much
rbtree has it's uses cases. I wanted a sorted array because I
want to include it in a benchmark suite and study it's time and
space complexity. No applicat
On 11/15/22 06:05, Siarhei Siamashka wrote:
> Ali commented that "the
> compiler cannot do anything about it in all cases and we wouldn't want
> it to spend infinite amount of time to try to determine everything".
Yes, that's my understanding.
> This sounds like he justifies the compiler's fail
On Tuesday, 15 November 2022 at 14:26:22 UTC, Imperatorn wrote:
Side-note, you don't override interface members, you implement
them.
My knowledge of D is still modest, most likely, I just didn't
know that override with interfaces can not be used. Thanks for
the hint!
On Tuesday, 15 November 2022 at 14:09:01 UTC, bauss wrote:
If you cast to Object and use classinfo.name then you get the
expected result of B.
Thanks! 😌
On Tuesday, 15 November 2022 at 12:25:22 UTC, Hipreme wrote:
On Tuesday, 15 November 2022 at 11:42:59 UTC, Alexander Zhirov
wrote:
As shown you can use Object for this.
Side-note, you don't override interface members, you implement
them.
```d
interface A
{
string
On Tuesday, 15 November 2022 at 11:42:59 UTC, Alexander Zhirov
wrote:
Is there any way to get the name of class B?
```d
interface A {
string text();
}
class B : A {
override string text() {
return ": It's ok!";
}
}
void main() {
A[] a = cast(A[]) new B[3];
B b = new
On Tuesday, 15 November 2022 at 13:16:18 UTC, Paul Backus wrote:
D's safety model is the same. In `@safe` code, D will reject
anything that the compiler cannot say for sure is memory safe.
However, unlike in Rust, `@safe` is not the default in D, so
you must mark your code as `@safe` manually i
On Tuesday, 15 November 2022 at 13:01:39 UTC, Siarhei Siamashka
wrote:
Well, there's another way to look at it:
https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html
('Unsafe Rust exists because, by nature, static analysis is
conservative. When the compiler tries to determine whether or
not
On Tuesday, 15 November 2022 at 06:44:16 UTC, Ali Çehreli wrote:
In summary, you are right but the compiler cannot do anything
about it in all cases and we wouldn't want it to spend infinite
amount of time to try to determine everything.
Well, there's another way to look at it:
https://doc.ru
On Tuesday, 15 November 2022 at 11:42:59 UTC, Alexander Zhirov
wrote:
Is there any way to get the name of class B?
```d
interface A {
string text();
}
class B : A {
override string text() {
return ": It's ok!";
}
}
void main() {
A[] a = cast(A[]) new B[3];
B b = new
On Tuesday, 15 November 2022 at 12:25:22 UTC, Hipreme wrote:
You can do it as `val.classinfo.name`
Yes, I have already done so, but the result is the same, actually
:)
```d
app.A: It's ok!
app.A: It's ok!
app.A: It's ok!
```
Is there any way to get the name of class B?
```d
interface A {
string text();
}
class B : A {
override string text() {
return ": It's ok!";
}
}
void main() {
A[] a = cast(A[]) new B[3];
B b = new B();
fill(a, b);
foreach (val ; a) {
writeln(typeof(va
18 matches
Mail list logo