I would like to have support for ordering content of a constant array at compile time.
I would like to have optimized lookup function for such an ordered constant array (binary search, hash index, etc, - whatever fits the purpose) to check if a variable has a match in the ordered constant array. The code generator could inline the lookup function if so was desired.
I guess you can say that I am looking for something like the "in" keyword for sets, but extended to work with any constant array (string, array of enumerable, array of number, or array of other constants such as class type references).
A specification syntax could look something like:
<arraytype> = {ordered {ascending | descending}} Vector<T>
Implicit methods associated with the type:
Vector<T>.Contains(const element: T):Boolean;
Vector<T>.ContainsAny(const array of T):Boolean;
Vector<T>.ContainsAll(const array of T):Boolean;
Vector<T>.Include(const element: T);
Vector<T>.Exclude(const element: T);
Example declaration:
type
TMyType = ordered ascending Vector<Char>;
const
InvalidChars : TMyType = ['\', ':', '.', '(', ')']; // I don't want to worry about order here
Example of use:
if InvalidChars.Contains(SomeCharacter) then ...
Today, I can create singleton objects that are ordered as part of the initialization code, but it becomes a lot of micro management code which isn't optimized for call performance, instead of easy to use code like "element in set" style code.
Delphi Programming - Real programmers write comments mostly in or about other peoples code.
Delphi Programming
and software in general.
Showing posts with label wishful. Show all posts
Showing posts with label wishful. Show all posts
Tuesday, November 8, 2011
Subscribe to:
Posts (Atom)
Programming Related Blogs
-
-
-
-
-
-
IceFest in Pennsylvania5 years ago
-
-
Aaron Swartz13 years ago
-
Setup IIS for Episerver CMS10 years ago
-
-
Never Defragment an SSD15 years ago
-
Welcome to BlogEngine.NET8 years ago
-
-
Somasegar's blog - Site Home - MSDN Blogs10 years ago
-
-
-
-
CodeSOD: The Date and Time and Time16 hours ago
-