www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/20/12:43:50

From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Mouse Events Problem
Date: Wed, 20 Oct 1999 14:00:12 +0200
Organization: NetVision Israel
Lines: 32
Message-ID: <Pine.SUN.3.91.991020135953.22660a-100000@is>
References: <7uitf2$qor$1 AT news8 DOT svr DOT pol DOT co DOT uk> <7uiv4d$6bq$1 AT solomon DOT cs DOT rose-hulman DOT edu>
NNTP-Posting-Host: is.elta.co.il
Mime-Version: 1.0
X-Trace: news.netvision.net.il 940420733 20727 199.203.121.2 (20 Oct 1999 11:58:53 GMT)
X-Complaints-To: abuse AT netvision DOT net DOT il
NNTP-Posting-Date: 20 Oct 1999 11:58:53 GMT
X-Sender: eliz AT is
In-Reply-To: <7uiv4d$6bq$1@solomon.cs.rose-hulman.edu>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Tue, 19 Oct 1999, Damian Yerrick wrote:

> Hammy <darren AT grayce DOT freeserve DOT co DOT uk> wrote in message
> news:7uitf2$qor$1 AT news8 DOT svr DOT pol DOT co DOT uk...
> > Probably not the best newsgroup but heres my problem.
> > Im trying to write an event manager for a mouse. The idea
> > I have so far is this: i have created a structure that holds the
> > coordinates of rectangles for which a mouse can click in a
> > trigger an event.  Also in the struct I have a byte for the button
> 
> Limit yourself to 128 buttons on screen? I'd use an int.

A byte can support 255 buttons.  How many buttons can you feasibly
have on screen without bewildering people?

But I do agree that, if there's no good reason to use a byte, an int
should be the default choice.

> >     I have this structure as a linked list and have ordered it in
> > active/disable, now, i can image this being rather slow the more events i
> > have.  So, does anyone know of the a better way to do this?
> 
> qsort() the rectangles by top coordinate and use a
> bsearch().

For small numbers of items, such as what we are talking here, it
usually doesn't pay off to sort them.  Linear search through the
linked list should be enough.  Later, if the program seems to run
slowly, profile it, and only replace the search algorithm if the
profile says that search is the hot spot.  (I don't expect that to be
the case, for such a short list.)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019