using System;
using System.Runtime.InteropServices;

namespace SharpQuake
{
	[StructLayout(LayoutKind.Sequential, Pack = 1)]
	internal class link_t
	{
		public link_t Prev
		{
			get
			{
				return this._Prev;
			}
		}

		public link_t Next
		{
			get
			{
				return this._Next;
			}
		}

		public object Owner
		{
			get
			{
				return this._Owner;
			}
		}

		public link_t(object owner)
		{
			this._Owner = owner;
		}

		public void Clear()
		{
			this._Next = this;
			this._Prev = this;
		}

		public void ClearToNulls()
		{
			this._Prev = (this._Next = null);
		}

		public void Remove()
		{
			this._Next._Prev = this._Prev;
			this._Prev._Next = this._Next;
			this._Next = null;
			this._Prev = null;
		}

		public void InsertBefore(link_t before)
		{
			this._Next = before;
			this._Prev = before._Prev;
			this._Prev._Next = this;
			this._Next._Prev = this;
		}

		public void InsertAfter(link_t after)
		{
			this._Next = after.Next;
			this._Prev = after;
			this._Prev._Next = this;
			this._Next._Prev = this;
		}

		private link_t _Prev;

		private link_t _Next;

		private object _Owner;
	}
}
