python like datastructures as databases code examples

monkyyy crazymonkyyy at gmail.com
Mon Jul 21 16:13:44 UTC 2025


On Monday, 21 July 2025 at 14:56:41 UTC, Serg Gini wrote:
> But array doesn't look right..
> If you want a balanced ("always sorted") structure with 
> "filter" (ability to make some requests for the data) - this 
> looks more like some Tree structure

Your thinking in classical theory and textbook read`n; practice 
has no such restriction

```d
struct sortedarray(A){
     A array;
     bool issorted;
     void opOpAssign(string s:"~",T)(T t){
	issorted=false;
         array~=t;
     }
     alias get this;
     ref get(){
         if( ! issorted){
             import std;
             array.sort;
         }
         return array;
}}
unittest{
     sortedarray!(int[]) array;
     array~=[1,4,5,7,8,2];
     import std;
     array.writeln;
}
```

> I'm not sure what you are trying to do.

syntax test, concept generation, gather'n pieces


More information about the Digitalmars-d-learn mailing list