MᏫᎻᎯᎷᎷᎬᎠ
rust is not abi stable
Edition preserve the backward compatibility
MᏫᎻᎯᎷᎷᎬᎠ
By providing compiler switch on the crate level
MᏫᎻᎯᎷᎷᎬᎠ
That's why Epochs is proposed to solve this issue
MᏫᎻᎯᎷᎷᎬᎠ
In the Abstract section: This paper proposes a mechanism to evolve the C++ language syntax while retaining backward and forward compatibility by adding an opt-in module-level switch to change the meaning of source code. No ABI impact section: It is a strict requirement that epochs must not affect ABI. Epochs will not introduce any change that results in ABI breakage - their role is to sligthly affect how source code tranforms to an AST and whether it is considered well-formed or ill-formed. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1881r0.html
MᏫᎻᎯᎷᎷᎬᎠ
And still I don't fully understand why the proposal was rejected
MᏫᎻᎯᎷᎷᎬᎠ
It seems like a game changing feature
Anonymous
That's why Epochs is proposed to solve this issue
Epoch is just one suggestion. It was rejected because there is no implementation and not known if one can be even implemented. It will take a long time to mature because modules themselves are not supported completely by any major compilers and epochs as proposed today depends a lot on modules. Here is another proposal for ABI stability http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2123r0.html which doesnt require extensive changes.
MᏫᎻᎯᎷᎷᎬᎠ
Even modules are not implemented fully as you've said and got standardized
Anonymous
Edition preserve the backward compatibility
you can link a library compiled with -std=gnu++11 and a library compiled with -std=c++20 without any issues (as long as the same toolchain is used). am i missing something?
Anonymous
I don't think standardization process is affected by the vendors(GCC, clang...) implementation
IT DOES. Why do you think export keyword introduced in 2003 was deprecated when launched with so much fanfare? Because only one compiler decided to implement it and the others did not.
Anonymous
Even modules are not implemented fully as you've said and got standardized
In discussions with compiler vendors and tool writers. Epochs will not make it unless modules reaches a level of maturity which it looks like will take beyond 2025 given that companies are just starting to adopt C++17
Anonymous
>
Yes but you were also saying you didnt know why epochs got rejected. It got rejected because modules hasn't matured yet
MᏫᎻᎯᎷᎷᎬᎠ
Yes but you were also saying you didnt know why epochs got rejected. It got rejected because modules hasn't matured yet
So, if modules got matured as it seems it will There is a high chance for Epochs to get into the standard
Anonymous
So, if modules got matured as it seems it will There is a high chance for Epochs to get into the standard
Maybe maybe not. The current proposal doesnt say or propose how it can be implemented. Without that it will be difficult for it to be accepted. With modules maturing, there might be a better proposal or even one with an implementation to give it a nudge in the right direction.
MᏫᎻᎯᎷᎷᎬᎠ
I really hope so
Anshul
void deleteAtMiddle(Node *&head,int pos) { if(head==NULL or pos==0) { deleteAtHead(head); return; } int jumps=1; Node *p=head; while(jumps<=pos-1) { p=p->next; } Node *n=p->next; p->next=n->next; n->next->prev=p; delete n; return; }
Anshul
i write this code to delete a node in the middle of linked list but this doesn't work well
Anshul
help me find out the error
Anshul
this is the delete at head fun.
Anshul
void deleteAtHead(Node *&head) { if(head==NULL) { return; } Node *temp=head->next; delete head; temp->prev=NULL; head=temp; return; }
Anshul
> Node *&head why
because if someone calls this function when head is pointing to null or there is only one element in the linked list, then i need to update head of linked list. i'm not making a class for linked list. i am keeping track of head of linked list in my main function only.
Anshul
yeah
Anshul
thanks i got it now!
Anshul
How should i write it?
Anshul
void deleteAtHead(Node *&head) { if(head==NULL) { return; } if(head->next==NULL) { delete head; head=NULL; return; } Node *temp=head->next; delete head; temp->prev=NULL; head=temp; return; } this corrects the delete at head function??
Anshul
void deleteAtHead(Node *&head) { if(head==NULL) { return; } if(head->next==NULL) { delete head; head=NULL; return; } Node *temp=head->next; delete head; temp->prev=NULL; head=temp; return; } int length(Node *head) { int cnt=0; while(head!=NULL) { cnt++; head=head->next; } return cnt; } void deleteAtTail(Node *&head) { if(head==NULL or head->next==NULL) { deleteAtHead(head); return; } Node *p=head; while(p->next->next!=NULL) { p=p->next; } Node *tail=p->next; delete tail; p->next=NULL; } void deleteAtMiddle(Node *&head,int pos) { if(head==NULL or pos==0) { deleteAtHead(head); return; } if(pos>=length(head)) { deleteAtTail(head); return; } int jumps=1; Node *p=head; while(jumps<=pos-1) { p=p->next; jumps++; } Node *n=p->next; p->next=n->next; if(n->next!=NULL) { n->next->prev=p; } delete n; return; }
Anshul
will this handle all the corner cases???
Anonymous
bool delete_at_head(node **head) { return delete_at_pos(head, 0); } bool delete_at_tail(node **head) { auto length = length(*head); return length ? delete_at_pos(head, length - 1) : false; }
Anonymous
std::cout << "Hello there" << "\n"
Anonymous
*head = temp->next
This sets head to the node after temp. But what about the the node before temp. Its next link will be pointing to temp right?
Anonymous
And why are you even changing head pointer? You are just deleting a node somewhere in between. Why should head be changed to the node after the one deleted?
Anonymous
This sets head to the node after temp. But what about the the node before temp. Its next link will be pointing to temp right?
assume n is being deleted. *head = temp->next changes n->prev->next to n->next; (or the actual head of the list if head was pointing there) temp->next->prev = temp->prev; changes n->next->prev to n->prev
Anonymous
*head is the node to be deleted, not head
Anonymous
head contains the address of a next pointer (or an actual head pointer coming from outside)
Head could be the actual head pointer of the list. You shouldnt be changing that. node* temp = *head; Here *head is the node to be deleted. You set temp to that node. Now temp is the node to be deleted *head = temp->next; Here you set head to the node after temp that is the node after the node to be deleted. Neither of this code sets temp->prev->next to *head which is what I am talking about. You then go on to delete temp after setting temp->next->prev to temp->prev You have not changed temp->prev->next anywhere.
Anonymous
head either comes from outside using /* something something node *head something something */ delete_at_pos(&head, n); or changes at head = &((*head)->next);
Anonymous
head either comes from outside using /* something something node *head something something */ delete_at_pos(&head, n); or changes at head = &((*head)->next);
Ok let me address this one by one. Suppose say I have this list l and head is a pointer to the first node in this list. node* head = 1st pointer. If I call delete_at_pos(&head, n) my head pointer would have been changed by your code. This is not correct design. Now coming to the other point, *head = temp->next doesnt set the next link in temp->prev. I am not sure how you are saying that it does so. Let me test this code later.
Anonymous
Ok let me address this one by one. Suppose say I have this list l and head is a pointer to the first node in this list. node* head = 1st pointer. If I call delete_at_pos(&head, n) my head pointer would have been changed by your code. This is not correct design. Now coming to the other point, *head = temp->next doesnt set the next link in temp->prev. I am not sure how you are saying that it does so. Let me test this code later.
first point. yes. head would point to the new first node of the list now (which may be nullptr). why would it be bad design though? the delete_at_pos() is a modifier for the entire list object, so it asks for a pointer to the list (instead of the first node) and modifies the list as it sees fit. ideally there should be a using list = node * in the header file so the user's code should look like list l1 = create_list(first_elem); /* something something */ delete_at_pos(&l1, n); second point sure
Anonymous
first point. yes. head would point to the new first node of the list now (which may be nullptr). why would it be bad design though? the delete_at_pos() is a modifier for the entire list object, so it asks for a pointer to the list (instead of the first node) and modifies the list as it sees fit. ideally there should be a using list = node * in the header file so the user's code should look like list l1 = create_list(first_elem); /* something something */ delete_at_pos(&l1, n); second point sure
You are deleting a node at some position in the list. That shouldnt change the head pointer. Ideally you shouldnt be changing the pointer passed in by the user at all without knowing what he is using it for. That is why I said it is not good design. He could be using that pointer as the head for his list. If he wanted to delete the 4th element, it shouldnt change the head pointer at all. Only in the case where it deletes the first node should the head pointer be changed. Not in any other cases.
Anonymous
I will check your code near a system. I am not sure if the prev node will be affected. But like you said, I missed the Node** and was interpreting your code as it being Node*. Will check it later.
Anonymous
I will check your code near a system. I am not sure if the prev node will be affected. But like you said, I missed the Node** and was interpreting your code as it being Node*. Will check it later.
no your interpretation was consistent throughout. i deleted that message. *head is the node to be deleted == delete *head; node is the node to be deleted == delete node;
Anonymous
no your interpretation was consistent throughout. i deleted that message. *head is the node to be deleted == delete *head; node is the node to be deleted == delete node;
No it was my mistake. The actual head pointer passed in would not be affected by your code. You are just resetting head here : head = &((*head)->next); which seems good. I got confused with a double pointer and a single pointer. Will have to check the logic for prev problem again just to be sure. Cant break my head over it on my phone but.
Anonymous
😁.
Yeah it works. I tested it first before reading the code and then understood it 😉
Anonymous
if i use pointer indexes to find pointer id's, how can i update my index's if my index's swap? eg count 1 idx 0, id 0, my array id 0 count 2 idx 0, id 0, my array id 0 idx 1, id 1, my array id 1 count 1 idx 0, id 1, my array id 0 count 2 idx 0, id 1, my array id 0 idx 1, id 0, my array id 1
Anonymous
assuming fixed size array is used
Anonymous
eg https://gist.github.com/2ae50995de60e7849358313d74827e99
Anonymous
ok i needed to use pointerIndex instead of pointerId when computing the array index 🙂
Anonymous
is there a way to find the KEY with the max number of values in it? in unordered_map? I know count() but for that I need to know the key
hmm
Hi
hmm
I am ankit
hmm
Nafiu Salisu Muhammad: Please help me with this assignment Exercises1:Write an algorithm to find the square of a number. Display the pictorial representation of the algorithm using a flowchart. Exercise 2:Draw a flowchart to solve the problem of a non-functioning light bulb. Exercise 3:Write an algorithm to check whether a number is odd or even. Present your algorithm in Psuedocode and flowchart
hmm
Solve problems
hmm
Above
hmm
1 am now 1st year student
Pavel
Solve problems
Have you read the rules? We can help if you have some code written and some troubles/questions about it or some other specific questions/troubles, but not doing your homework/assignment for you. How would you learn if someone does your practice instead of you?
Anonymous
is there a way to find the KEY with the max number of values in it? in unordered_map? I know count() but for that I need to know the key
Do you mean an unordered_multimap? An unordered_map will have only one value associated with each key
Anonymous
Do you mean an unordered_multimap? An unordered_map will have only one value associated with each key
Oh shit Yes sorry I can create a list as the values Now say, for the list, do I iterate over it and count the no of nodes?
Anonymous
Oh shit Yes sorry I can create a list as the values Now say, for the list, do I iterate over it and count the no of nodes?
Yes. You will have to iterate over the map and find the list with the longest length. The map interface doesnt support these sort of queries. If you need to do such queries frequently then an alternative way would be to use two multi maps where the 2nd multi map will store the first map's key as value and will use the first map's value (actually the list length) as key.
Jk
/get cbook
Anonymous
Hi is it possible for the condition of a loop to be a if statement for example while ( if else statements)
mito
Hi is it possible for the condition of a loop to be a if statement for example while ( if else statements)
Don't know whether it's syntactically possible other than ternary operators.. But you can put the if statements in a function and call the function in the while statement condition part...
Golden Age Of
Use pairs
Golden Age Of
Use tuples
Anonymous
Should I learn DirectX11 or OpenGL for windows?
Mar!o
Should I learn DirectX11 or OpenGL for windows?
Well OpenGL is cross Plattform so it works on Linux too