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ᏫᎻᎯᎷᎷᎬᎠ
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?
MᏫᎻᎯᎷᎷᎬᎠ
Anonymous
>
Yes but you were also saying you didnt know why epochs got rejected. It got rejected because modules hasn't matured yet
MᏫᎻᎯᎷᎷᎬᎠ
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.
Anonymous
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.
Anonymous
Anshul
yeah
Anshul
thanks i got it now!
Anonymous
Anonymous
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
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
Anonymous
std::cout << "Hello there" << "\n"
Anonymous
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
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
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
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
Anonymous
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.
but that is what happens
list -> 1, 2, 3, 4, 5
delete_at_pos(&list, 0)
list -> 2, 3, 4, 5
delete_at_pos(&list, 2)
list -> 2, 3, 5
Anonymous
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
Pavel
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
Anonymous
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)
Anonymous
Golden Age Of
Use pairs
Golden Age Of
Use tuples
Anonymous
Should I learn DirectX11 or OpenGL for windows?