<commit_before><commit_msg>Implementing Doubly Linked List using XOR<commit_after>// Implementing a memory-efficient linked list

#include<iostream>

using namespace std;

struct Node{
int data;
struct Node *npx;	// XOR of next & prev node
};

// returns XORed value of the node addresses
struct Node *XOR(struct Node *a, struct Node *b){
	return (struct Node*)((unsigned long)(a) ^ (unsigned long)(b));
}

// Insert Node at beginning of XORed linked list
void insert(struct Node **head, int x){
	struct Node *newNode = new Node;
	newNode->data = x;
	newNode->npx = XOR(*head, NULL);

	if(*head != NULL){
		struct Node *next = XOR((*head)->npx, NULL);
		(*head)->npx = XOR(newNode, next);
	}

	*head = newNode;
}

void printList(struct Node *head){
	struct Node *curr = head;
	struct Node *prev = NULL;
	struct Node *next;

	cout<<"Elements of Linked List\n";
	while(curr != NULL){
		cout<<curr->data<<" ";
		next = XOR(prev, curr->npx);
	prev = curr;
	curr = next;
	}
cout<<"\n";
}

int main (){
struct Node *head = NULL;
insert(&head, 10);
insert(&head, 20);
insert(&head, 30);
insert(&head, 40);
printList(head);
return 0;
}
{'fraction_non_alphanumeric': 0.16326530612244897, 'fraction_numerical': 0.007985803016858917, 'mean_word_length': 4.3971291866028706, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5959035', 'n_tokens_mistral': 414, 'n_tokens_neox': 401, 'n_words': 131}