KODLAT
using System;
namespace ConsoleApp1
{
class Node
{
public object veri;
public Node onceki, sonraki;
public Node(object veri)
{
this.veri = veri;
this.onceki = null;
this.sonraki = null;
}
}
public class BList
{
Node ilknode; // Corrected to initialize later
Node sonnode; // Corrected to initialize later
public int s;
public BList()
{
this.ilknode.sonraki = this.sonnode;
ilknode = new Node(null); // Initialize the head node with null
sonnode = new Node(null); // Initialize the tail node with null
ilknode.sonraki = sonnode; // Connect head to tail
sonnode.onceki = ilknode; // Connect tail back to head
s = 0; // Initialize the size
}
public void ekle(object veri)
{
Node yeninode = new Node(veri);
yeninode.onceki = sonnode.onceki; // Set the previous of new node
yeninode.sonraki = sonnode; // Set the next of new node to tail
sonnode.onceki.sonraki = yeninode; // Set the next of the current last node to new node
sonnode.onceki = yeninode; // Set tail's previous to new node
yeninode.sonraki = sonnode;
s++; // Increment the size
}
public void listele()
{
Node aktif = new Node("");
aktif = sonnode;
}
}
}