From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Overlays as an AA-tree Date: Fri, 03 Feb 2017 08:55:15 -0500 Message-ID: References: <87d1jylv43.fsf@fastmail.com> <87fujv64mn.fsf@hochschule-trier.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1486130156 25213 195.159.176.226 (3 Feb 2017 13:55:56 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 3 Feb 2017 13:55:56 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Feb 03 14:55:53 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cZeLB-0006OA-0N for ged-emacs-devel@m.gmane.org; Fri, 03 Feb 2017 14:55:53 +0100 Original-Received: from localhost ([::1]:34887 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZeLG-0006pM-Lw for ged-emacs-devel@m.gmane.org; Fri, 03 Feb 2017 08:55:58 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56745) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZeKn-0006cd-Qc for emacs-devel@gnu.org; Fri, 03 Feb 2017 08:55:31 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZeKi-00073B-Vx for emacs-devel@gnu.org; Fri, 03 Feb 2017 08:55:29 -0500 Original-Received: from [195.159.176.226] (port=52456 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cZeKi-00072R-PU for emacs-devel@gnu.org; Fri, 03 Feb 2017 08:55:24 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1cZeKZ-00050Y-PG for emacs-devel@gnu.org; Fri, 03 Feb 2017 14:55:15 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 35 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:SvhYLq0N+mHOL57Z5sTcP2qpZuY= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:211929 Archived-At: > Anyway, my attempt is to use the RB-tree from alloc.c and add some > node-attributes: > 1. max_end :: Holds the maximum E value of this node's sub-tree and > bounds the complexity of queries in terms of their result, i.e. number > of intervals. (The so called ,,Augmented Tree'' approach to Interval > Trees (which is actually just an example for how to augment a tree in > the book).) Sounds good. > 2. offset :: The amount of shift of this node's sub-tree relative to > its parent and applying to all position values (begin,end,max_end). > This should limit the time it takes to modify the tree after an > insertion/deletion in terms of intersecting intervals. Sounds good. > 3. modified_tick :: Essentially just a flag, indicating that all > parent offsets have been applied to this node. This would allow for > constant time access on B/E for repeated accesses. But that can't be a boolean, right (otherwise how do you plan to set it to true on all overlays after the insertion point, without paying an O(n) cost)? So, by the "tick" name, I assume you keep a kind of MODIFF counter at the root of the tree which is incremented every time an insertion/deletion is performed, and you keep a copy of that MODIFF value in the nodes, to remember the last time the start/end value were recomputed, so the "flag" is really (modified_tick == root->modified_tick). If so, this sounds good as well. Stefan