108 lines
2.2 KiB
C#
108 lines
2.2 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data.SqlTypes;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using System.Text;
|
|
|
|
namespace StgSharp
|
|
{
|
|
public abstract class INode<T> where T : INode<T>
|
|
{
|
|
[NotNull]
|
|
protected ContainerNode<T> _id;
|
|
|
|
internal ContainerNode<T> ID
|
|
{
|
|
get { return _id; }
|
|
}
|
|
|
|
internal ContainerNode<T> Previous
|
|
{
|
|
get { return _id._previous; }
|
|
set { _id._previous = value; }
|
|
}
|
|
|
|
internal ContainerNode<T> Next
|
|
{
|
|
get { return _id._next; }
|
|
set { _id._next = value; }
|
|
}
|
|
|
|
public INode()
|
|
{
|
|
_id = new ContainerNode<T>(this as T);
|
|
}
|
|
|
|
internal void SetId(ContainerNode<T> tContainer)
|
|
{
|
|
_id = tContainer;
|
|
}
|
|
|
|
internal void SelfDestrcut()
|
|
{
|
|
_id._previous._next = _id._next;
|
|
_id._next._previous = _id._previous;
|
|
_id._next = null;
|
|
_id._previous = null;
|
|
GC.Collect();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
public class ContainerNode<T> : INullable where T : INode<T>
|
|
{
|
|
internal readonly T _value;
|
|
|
|
[AllowNull]
|
|
internal ContainerNode<T> _previous;
|
|
[AllowNull]
|
|
internal ContainerNode<T> _next;
|
|
|
|
internal ContainerNode()
|
|
{
|
|
}
|
|
|
|
|
|
public ContainerNode(T t)
|
|
{
|
|
_value = t;
|
|
_previous = new ContainerNode<T>();
|
|
_next = new ContainerNode<T>();
|
|
}
|
|
|
|
public virtual ContainerNode<T> Previous
|
|
{
|
|
get { return _previous; }
|
|
set { _previous = value; }
|
|
}
|
|
|
|
public ContainerNode<T> Next
|
|
{
|
|
get { return _next; }
|
|
set { _next = value; }
|
|
}
|
|
|
|
public T Value
|
|
{
|
|
get { return _value; }
|
|
}
|
|
|
|
public bool IsNull
|
|
{
|
|
get;
|
|
}
|
|
|
|
public void Remove()
|
|
{
|
|
_previous.Next = _next;
|
|
_next.Previous = _previous;
|
|
_next = default(ContainerNode<T>);
|
|
_previous = default(ContainerNode<T>);
|
|
}
|
|
|
|
}
|
|
}
|