[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology

Name
Options
Comment
Verification
4chan Pass users can bypass this verification. [Learn More] [Login]
File
  • Please read the Rules and FAQ before posting.
  • You may highlight syntax and preserve whitespace by using [code] tags.

08/21/20New boards added: /vrpg/, /vmg/, /vst/ and /vm/
05/04/17New trial board added: /bant/ - International/Random
10/04/16New board for 4chan Pass users: /vip/ - Very Important Posts
[Hide] [Show All]


[Advertise on 4chan]


File: 1773749413473473.jpg (3.5 MB, 2520x3538)
3.5 MB
3.5 MB JPG
What are you working on, /g/?

Previous: >>108355732
>>
Who would put a plate of fruit on such a small ledge?
>>
In order node generator:
struct Node {
char c;
Node* l{};
Node* r{};
};

class NodeGenerator{
static const int max = 50;
const Node* v[max];
int size = 0;
const Node* cur;
bool right;
struct It{
NodeGenerator* p;
const Node& operator*() const {return *p->cur;};
bool operator!=(const It& o) const {return p != o.p;}
void operator++() {p = p->next();};
};
public:
NodeGenerator(const Node& root) : size{0}, cur{&root}, right{false} {}
NodeGenerator* next() {
if (right) cur = cur->r;
while (size || cur) {
if (cur) {
if (size == max) break;
v[size++] = cur;
cur = cur->l;
} else {
cur = v[--size];
right = true;
return this;
}
}
return nullptr;
};
It begin() { return It{next()};}
It end() const { return It{nullptr};}
};

extern "C" int putchar(int);
int main() {
Node tree[] {
{'D', tree + 1, tree + 2},
// |
// +---------------+----------------+
// | |
{'B', tree + 3, tree + 4}, {'F', tree + 5, tree + 6},
// | |
// +---------+-------------+ +-----------+-------------+
// | | | |
{'A'}, {'C'}, {'E'}, {'G'}
};
for (auto node : NodeGenerator{*tree}) putchar(node.c);
}
>>
>>108395758
>const Node* v[max];
Learn how to do memory.
>>
>>108395758
you stole this example from std::generator
>>
>>108395775
Are you blind?
Where is being used std::generator?
>>108395771
Retard take.
>>
>>108395806
Go be autistic somewhere else, we already have enough.
>>
>>108395806
https://en.cppreference.com/w/cpp/coroutine/generator.html#Example
>>
>>108395824
Get lost retard.
>>108395827
That example uses std::generator, you moron.
>>
>>108395840
Make me, autist.
>>
>>108395853
Done.
>>
>>108395861
"In your head" doesn't count, autist.
>>
>>108395863
You are already autistic AF.
>>
>>108395867
Certifiably not, but nice projection anyway.

Autist.
>>
File: 1773587906643918.jpg (65 KB, 811x519)
65 KB
65 KB JPG
>>108395512
Unused ledge is wasted ledge
>>
File: pkmonbgw.webm (2.88 MB, 598x516)
2.88 MB
2.88 MB WEBM
I largely rewrote the background pixel rendering so hopefully it works better and I can split up the rendering over scanline time later (it's all just done in a block right now, essentially one CPU cycle).
There seems to be a timing issue at the end of the intro animation, the Gengar scrolls before the screen goes fully white, I'll have to look into that (I'm not sure the trigger for that, I might have the DIV a little too fast, not sure if that is being used, I would think frame count).
Next up, sprite rendering. 4450 lines.
>>
>>108395972
That already didn't work as an excuse for programs thanks to caches.
>>
File: 1771365170630599.png (799 KB, 1070x1070)
799 KB
799 KB PNG
>reading some dude's crazy leetcode solution (Swift)
>he's using structs instead of classes for his objects
>but structs have two big limitations:
>>you can't modify any of the variables in a struct if you defined it as a constant (this doesn't happen with classes)
>>you also can't define any function inside of a struct that would change the variables, because swift doesn't know at compile time if the struct is going to be a variable or a constant
>introduce the "mutating" keyword - you can define a function inside of a struct that modifies it's variables, and if it's "mutating" you can only call it when the struct is a variable (instead of a constant)
>so now you've recreated the functionality of a class, but it's a struct, and has more boilerplate code

>why?........
>presumably using structs like this is thread safe or some shit
>but there's no threading or concurrency in leetcode environments (at least I don't think there is)
????????????????????
>>
I pray every day that both the LLM bubble and the closure of the strait of Hormuz last much longer. I want to see high hardware and energy prices, so that software developers either lose their job because no one uses the result of their incompetent work, or they finally start writing good software again.
>inb4 they will never do that
Then I suppose they'll be OK going hungry.
>>
I've never subscribed to such websites but do you guys know a good coding challenges website that'll teach/help me play with datastructures/algorithms and just train my brain for programming tasks.
I feel like it's the last thing to resolve, my low IQ when it comes to that kind of thing. Which one is the best of them all, I'm willing to pay a subcription for a good one. But only one.
>>
should I use select, poll, or epoll to read from a keyboard's event* file? my understanding is:
>select is old and busted, but also has the least overhead if you're just doing a single file and low throughput
>poll is better when you start having multiple files but still has low throughput
>epoll is just poll without throughput issues
is that a fair assessment?
>>
>>108396703
That would be a bit of an oversimplification.
select has a finite (like 1024?) limit on the actual file descriptor value that it can watch. Can actually be relevant on server programs.
- Both poll and select are O(n) to check the results, epoll is O(1)
- epoll has syscall overhead from adding or removing files from being watched. Can be relevant if you're doing this very often.
- epoll can do edge-triggered rather than level-triggered, which is helpful sometimes.

I don't think there really is much reason to ever use select over poll.
If you're doing a more "typical event loop" type thing, epoll is generally easier to use.
If you're just watching a handful of files (that ideally are static), poll is fine.
If you're going for hardcore shit, you use io_uring.
>>
File: 1765995157476081.jpg (17 KB, 278x278)
17 KB
17 KB JPG
t-there's no classes in rust?



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.