Path: csiph.com!1.us.feeder.erje.net!feeder.erje.net!1.eu.feeder.erje.net!weretis.net!feeder4.news.weretis.net!storethat.news.telefonica.de!feedme.news.telefonica.de!telefonica.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.java.programmer Subject: Re: Wanted: List of intervals Date: Sun, 19 Feb 2017 20:02:58 +0100 Lines: 25 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: individual.net TLvcAOjQhBLa5jpUPu+27gRDQBqMcoScaFDCn9COVLfNLdhIU= Cancel-Lock: sha1:lKNvMG+KXWZ6YYRRz2IDEISiHLQ= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 In-Reply-To: Xref: csiph.com comp.lang.java.programmer:36345 On 17.02.2017 04:32, Arne Vajh=C3=B8j wrote: > If that example is realistic then you can simply: > * allocate byte array of suitable length > * loop through intervals and mark corresponding bytes What are "corresponding bytes"? Do you want to use the byte array as a=20 bitset and mark all bits corresponding to values inside intervals? > * loop through bytes and create new intervals > > But if the numbers really need to be long aka is greater > than MAX_INT, then that strategy does not work. Even for ints the approach seems pretty wasteful, if I understood you=20 correctly. Kind regards robert --=20 remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/