473,786 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Storing Intervals or Ranges

Hi,

some time ago I've read a paper that advised to store intervals on discrete
values in the format [a;b[. One starts with the first element and finishes
with one past the last one.

However I do not remember the author, title or link of the paper. Does
anyone remember it?

Greetings
Christoph Bartoschek
Apr 25 '07 #1
9 2597
Christoph Bartoschek wrote:
Hi,

some time ago I've read a paper that advised to store intervals on discrete
values in the format [a;b[. One starts with the first element and finishes
with one past the last one.

However I do not remember the author, title or link of the paper. Does
anyone remember it?
This is exactly how C++ standard algorithms work.
Apr 25 '07 #2
red floyd wrote:
This is exactly how C++ standard algorithms work.
Yes, but the paper gave some rationale why this is better than using [a;b]
or other schemes.

Christoph
Apr 25 '07 #3
Christoph Bartoschek wrote:
Hi,

some time ago I've read a paper that advised to store intervals on discrete
values in the format [a;b[. One starts with the first element and finishes
with one past the last one.
Such an interval is known as a "half-open" interval. Notational
nitpick, the general format for such a range is [a, b).

Not sure of the location of the paper, but the rationale is that
one-past-the-end provides a not present indicator, much like a NULL
pointer would.

Apr 25 '07 #4
Christoph Bartoschek wrote:
Hi,

some time ago I've read a paper that advised to store intervals on discrete
values in the format [a;b[. One starts with the first element and finishes
with one past the last one.

However I do not remember the author, title or link of the paper. Does
anyone remember it?
Google came up with this: http://www.siliconbrain.com/ranges.htm
Apr 25 '07 #5
red floyd wrote:
Such an interval is known as a "half-open" interval. Notational
nitpick, the general format for such a range is [a, b).
I used [a; b[ because this is the format we used in school (Germany). Forgot
to use the more international format.
Google came up with this: http://www.siliconbrain.com/ranges.htm
This is not the paper I remember. But thanks for the link.

Christoph
Apr 25 '07 #6
* Christoph Bartoschek:
red floyd wrote:
>This is exactly how C++ standard algorithms work.

Yes, but the paper gave some rationale why this is better than using [a;b]
or other schemes.
The number of elements in the range is onePastLast-first. With zero
elements, an empty range, onePastLast == first. Which is very
convenient for pointers or more general iterators.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Apr 25 '07 #7
On Apr 25, 5:40 pm, red floyd <no.s...@here.d udewrote:
Christoph Bartoschek wrote:
some time ago I've read a paper that advised to store intervals on discrete
values in the format [a;b[. One starts with the first element and finishes
with one past the last one.
Such an interval is known as a "half-open" interval. Notational
nitpick, the general format for such a range is [a, b).
Which doesn't work for decimal numbers, in localities where the
decimal separator is a comma. I'll use "[a,b)" if I know that
I'm only addressing the Anglo-Saxon world, "[a;b[" for the rest
of the world. (Note that where I live, a complex is represented
as "(r;i)", and not "(r,i)", as well.)

--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Apr 26 '07 #8
"Christoph Bartoschek" <ba********@gmx .dewrote in message
news:a8******** ****@barney.wes seling.pontohon k.de...
some time ago I've read a paper that advised to store intervals on
discrete
values in the format [a;b[. One starts with the first element and finishes
with one past the last one.
There are lots of reasons. Here is one that I personally consider to be
conclusive.

If you represent a range by its first and last elements (symmetric ranges),
then an empty range is an anomaly: You need to find way to represent not
just one but two distinct positions that do not correspond to any element.

If you represent a range by its first and one past its last elements
(asymmetric), then you always need a way to represent a position that
doesn't correspond to any element, but the difficulty in doing so is the
same regardless of the number of elements.

Moreover, assymetric ranges have the nice property that begin<=end at all
times, and begin==end if and only if the range is empty. With symmetric
ranges, begin==end if and only if the range has precisely one element, and
begin>end if the range is empty. This latter behavior is much less useful
if you are using iterators that support only == and != comparisons.

If this argument doesn't convince you, here are some others:

If you are using integer indices, you can use unsigned values to represent
an asymmetric range. You need signed values to represent a symmetric
range--to cater to the specific case of [0,-1] which is needed to represent
an empty range.

If you are using pointers to array elements, you have a problem in C or C++
representing an empty symmetric range because you are not generally allowed
to compute the address that precedes an array.
Apr 27 '07 #9
I am already convinced that one should represent ranges as it is done in the
standard library. However this is my concrete case:

How to store rectangles in the integer plane?

A rectangle can be represented with the following struct:

static const int XDIM = 0;
static const int YDIM = 1;

struct Rectangle {
int min[2];
int max[2];
};

The question is how to interpret the ranges in x-dimension and y-dimension.
Everyone I asked assumed that the point (max[XDIM], max{YDIM]) is included
in the rectangle. But this has the same drawbacks as with one dimensional
ranges. For example the rectangles

{{0, 0}, {3, 3}}
{{4, 0}, {6, 3]]

cover the whole area from (0, 0) to (6, 3), although there seems to be a
hole from (3, 0) to (4, 3). Several algorithms (union, removing
overlaps, ...) are harder to implement with this scheme.

But should one use half-open ranges against the intuition?

Christoph
Apr 28 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3088
by: Matt Saunders | last post by:
There's lots of ways of representing a hierarchical data structure in a relational database. These range from the trivially easy to implement in PHP (adjacency list; each node has an ID and a ParentID) to the fairly nightmarish (Tropashko's nested intervals). In starting this thread I'm not looking for a primer on any of these methods, which Google will happily provide; I'm looking to create a list of PHP implementations of any such...
2
1724
by: Ben O'Steen | last post by:
Scenario: ========= Using PyGame in particular, I am trying to write an application that will run a scripted timeline of events, eg at 5.5 seconds, play xxx.mp3 and put the image of a ball on screen, at 7.8 seconds move the ball up and down. At this point, I hear you say 'Oh, like Flash'. Yes, well... Like Flash, but I don't want to take this app in the same direction as Macromedia took Flash, nor do I (ever) want the two to be
1
1636
by: Mark Smith | last post by:
Hi Group, Are there any examples of class for storing fixed width number strings such as phone number and social security numbers. This class would do thing like valid that the number is all integers or hex and confirm that the number is the correct length. I f the number is to short return an error or not store the number, etc.
67
7711
by: PC Datasheet | last post by:
Transaction data is given with date ranges: Beginning End 4/1/06 4/4/06 4/7/06 4/11/06 4/14/06 4/17/06 4/18/06 4/21/06 426/06 4/30/06 I am looking for suggestions on how to find the date ranges where there were no transactions.
5
1857
by: toton | last post by:
Hi, I have a deque of Point class,. Point class have two fields x, and y. Now I want another class Character should point to a portion of the deque, and allow iteration only on the portion. Thus a deque<Characterwill point on the deque<Pointover different ranges. Both are dynamic in the sense, new character, and hence new point gets added, while old character and old points get removed. My question is, what the Character will store as...
6
1301
by: Lint Radley | last post by:
Hi Everyone, I need an opinion here on storing data for a program I am working on the processes DICOM images. Essentially, my program stores 25-45 (it varies depending on the user) ranges of pixel values to search the image for. Currently, I am using a .MDF database that requires SQL Express to be installed. For only 25-45 records it seems like overkill to me. That being said, I love the ability to easily update records, delete, add,...
3
1528
by: Snedker | last post by:
Hi there, I really need some input of how to approach my little assignment. A customer wants to exclude all US IP-ranges from accessing part of his website. From http://www.ipaddresslocation.org/ I've collected about 16,000 ranges in the format 208.202.120.0 208.203.111.255 208.203.114.0 208.203.244.127
1
1780
by: lenygold via DBMonster.com | last post by:
I found this query on older thread and i can not uderstand output interval pairs: How to find min and max values in date intervals: -------------------------------------------------- Input: CREATE TABLE INTERVALS (key CHAR(5) NOT NULL ,level CHAR(7) NOT NULL ,date_from DATE NOT NULL
7
10267
by: guido | last post by:
Hi, I'm looking for a container class that can map whole ranges of keys to objects - something like std::map, but not only for individual values for the key, but for whole ranges. Example: I want to be able to tell the container to return object a for every given key between 0 and 10, object c for every key between 11 and 500000 and object c for every key between 500001 and 599999, without having to
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9491
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10163
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10104
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9959
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5532
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.