aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/rbtree.cpp
AgeCommit message (Collapse)AuthorFilesLines
2017-03-03updated copyright to 2017Robin Haberkorn1-1/+1
2016-11-20optimized RBTree: avoid unnecessary virtual RBTree and RBEntry ↵Robin Haberkorn1-2/+2
implementation classes * whenever the implementation class was not exactly RBEntryType, it had to have a virtual destructor since RBTree cared about cleanup and had to delete its members. * Since it does not allocate them, it is consistent to remove RBTree::clear(). The destructor now only checks that subclasses have cleaned up. Implementing cleanup in the subclasses is trivial. * Consequently, RBEntryString no longer has to be virtual. HelpIndex and GotoTables are completely non-virtual now which saves memory (and a bit of cleanup speed). For QRegister, not much changes, though.
2016-11-20auto-completion of Q-Register names, goto labels and help topicsRobin Haberkorn1-0/+58
* Using a common implementation in RBTreeString::auto_complete(). This is very efficient even for very huge tables since only an O(log(n)) lookup is required and then all entries with a matching prefix are iterated. Worst-case complexity is still O(n), since all entries may be legitimate completions. If necessary, the number of matching entries could be restricted, though. * Auto completes short and long Q-Reg names. Short names are "case-insensitive" (since they are upper-cased). Long specs are terminated with a closing bracket. * Long spec completions may have problems with names containing funny characters since they may be misinterpreted as string building characters or contain braces. All the auto-completions suffered from this problem already (see TODO). * This greatly simplifies investigating the Q-Register name spaces interactively and e.g. calling macros with long names, inserting environment registers etc. * Goto labels are terminated with commas since they may be part of a computed goto. * Help topics are matched case insensitive (just like the topic lookup itself) and are terminated with the escape character. This greatly simplifies navigating womanpages and looking up topics with long names.
2016-11-20optimized red-black trees and common base class for string-keyed RB treesRobin Haberkorn1-2/+4
* the old implementation tried to avoid template programming by making the entry comparison function virtual. * The new RBTree implementation takes a template argument with the implementation of RBEntry. It is now partially conventional that the template argument must be actually derived from RBTree::RBEntry and must define a "compare" method. * As an advantage we now get static polymorphism (avoiding virtual calls and allowing for more compiler optimizations) and the the RBEntry implementation no longer has to be virtual. * The only RB-Trees actually used are string-keyed, though. Therefore there's a common base class RBTreeString now which defines two synonymous "key" and "name" attributes. * The entry base class RBEntryString is virtual again because we do not want to propagate the RBEntryType template parameter even further and the RBTree base class needs to destroy entries. This might be avoided by not defining a RBTree::clear() method, leaving this task to the implementations. At least QRegisters have to be virtual, though. * RBTreeString only depends on the strcmp() and strncmp() functions used now and only case-sensitive and case-insensitive versions are actually required, so we instantiate these templates statically in rbtree.cpp. This means there are still only two instantiations of the RBTree in the binary. * RBTreeString defines convenient wrappers for find() and nfind() to look up by string. This uses the RBEntryString base class, so no allocations whatsover are required for lookups and less space is wasted on the call stack. * A RBEntryOwnString base class is also provided which frees the implementations from memory managing the tree keys. * RBTreeString can now be used to add other common functionality like auto-completions for Q-Registers, goto labels and help topics. * some minor optimizations * updated TODO
2016-01-28updated copyright to 2016Robin Haberkorn1-1/+1
2015-02-11updated copyright to 2015Robin Haberkorn1-1/+1
2014-11-11added all of SciTECO's declarations to the "SciTECO" namespaceRobin Haberkorn1-0/+4
normally, since SciTECO is not a library, this is not strictly necessary since every library should use proper name prefixes or namespaces for all global declarations to avoid name clashes. However * you cannot always rely on that * Scintilla does violate the practice of using prefixes or namespaces. The public APIs are OK, but it does define global functions/methods, e.g. for "Document" that clashed with SciTECO's "TECODocument" class at link-time. Scintilla can put its definitions in a namespace, but this feature cannot be easily enabled without patching Scintilla. * a "SciTECO" namespace will be necessary if "SciTECO" is ever to be turned into a library. Even if this library will have only a C-linkage API, it must ensure it doesn't clutter the global namespace. So the old "TECODocument" class was renamed back to "Document" (SciTECO::Document).
2014-02-15updated Copyright to year 2014Robin Haberkorn1-1/+1
2013-01-19updated copyright (2012-2013)Robin Haberkorn1-1/+1
2012-12-04added copyright notice to every source fileRobin Haberkorn1-0/+17
2012-12-04first working version of autotools based build-systemRobin Haberkorn1-0/+4
2012-12-04autoconf preparation: move everything into src/ subdirRobin Haberkorn1-0/+5