Click here to Skip to main content
15,886,110 members
Articles / Programming Languages / C#

The List Trifecta, Part 1

Rate me:
Please Sign up or sign in to vote.
4.97/5 (21 votes)
20 May 2016LGPL321 min read 37.1K   161   40  
The A-list is an all-purpose list, a data structure that can support most standard list operation in O(log n) time and does lots of other stuff, too
using System;
using System.Collections.Generic;
using System.Diagnostics;
using NUnit.Framework;
using Loyc.Essentials;

namespace Loyc
{
	public interface ITags<T>
	{
		/// <summary>Returns a dictionary that can be used to store additional state
		/// beyond the standard content of the object.
		/// </summary><remarks>
		/// Tags is never null or read-only.
		/// <para/>
		/// Tags of AstNodes should normally hold transient or derived information,
		/// not information that is part of the node's syntax.
		/// <para/>
		/// Is is possible that Tags==this to reduce overhead.
		/// </remarks>
		IDictionary<Symbol, T> Tags { get; }
	}

#if false
	/// <summary>
	/// Interface for classes that allow "state variables" to be attached to them.
	/// </summary><remarks>
	/// This interface allows arbitrary data to be attached to an object, using Symbols
	/// as unique keys. Duplicate keys are not allowed, and the data must inherit from 
	/// ValueT. It's a good idea for attribute classes to implement 
	/// IDictionary<Symbol, ValueT> also.
	/// </remarks>
	public interface IExtraAttributes<ValueT>
	{
		ValueT GetTag(Symbol key);     // Returns null if key is null
		ValueT GetTag(string key);     // Returns null if key is null
		void SetTag(Symbol key, ValueT val); // Exception if key is null
		void SetTag(string key, ValueT val); // Exception if key is null
		bool RemoveTag(Symbol key); // Returns true if attribute existed
		bool RemoveTag(string key); // Returns true if attribute existed
		bool HasTag(Symbol key);    // Returns false if key is null
		bool HasTag(string key);    // Returns false if key is null
		IEnumerator<KeyValuePair<Symbol, ValueT>> TagEnumerator();
	}
#endif
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)


Written By
Software Developer None
Canada Canada
Since I started programming when I was 11, I wrote the SNES emulator "SNEqr", the FastNav mapping component, the Enhanced C# programming language (in progress), the parser generator LLLPG, and LES, a syntax to help you start building programming languages, DSLs or build systems.

My overall focus is on the Language of your choice (Loyc) initiative, which is about investigating ways to improve interoperability between programming languages and putting more power in the hands of developers. I'm also seeking employment.

Comments and Discussions