Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
Topic Title: Skip lists - extracting key/data pairs
Topic Summary:
Created On: 6-Oct-2003 23:05
Status: Post and Reply
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 6-Oct-2003 23:05
User is offline View Users Profile Print this message


Paul Miller

Posts: 376
Joined: 2-Oct-2002

Hi,

I have a feeling that DOORS Skip lists behave much in the same way as Hash lists in Perl, but I'll ask this question anyway.

Is there any way of extracting the key/data pairs in the same order that they were put into the Skip list?

It looks pretty much as though the order of extraction via a "For do" loop is a random affair just like Perl Hash lists but I'm hopeing that there might be a "hidden" alternative extraction function/routine that might do it.

-------------------------
Paul Miller
Specification Practices Specialist,
EuroCyber,
Melbourne, Australia.
Mobile: +61 (0)418 135 103
Web Site: http://www.eurocyber.biz
E-mail: miller@eurocyber.biz">pmiller@eurocyber.biz
Report this to a Moderator Report this to a Moderator
 6-Oct-2003 23:41
User is offline View Users Profile Print this message


Douglas Zawacki

Posts: 97
Joined: 14-Aug-2003

DOORs stores the address of the key in the skip list itself so unless there is a way to dereference the address, there is no way of printing out the key/data pairs as far as I can tell.

As messy as it may sound I have used 2 skip lists to achieve this effect. One to memorize the Key values and the other to memorize the data. But, this is usually a rare occasion when it needs to be done this way.

Also, remember that you can store the object itself in a skip list. That's one way of storing all information about an object in one skip list.
Report this to a Moderator Report this to a Moderator
 7-Oct-2003 15:07
User is offline View Users Profile Print this message


Dennis Lockshine

Posts: 113
Joined: 7-Apr-2003

Skip lists are sorted in ascending order by the key value, which must be unique. When using a for..do loop to parse the skip list, all data values will be returned in the order as defined by the value of the key. However, it is extrememly easy to extract the key/value pairs.

There are two types of skip lists: (1) those that have a string value for the key, and (2) those that do not. In the first case, try this example:

Module m=current
Object o
Skip stringList=createString
string s

// Put the objects in the skip list, sorted by the object identifier
for o in m do put(stringList, identifier o "", o)

// Get the objects in order, and get the key of the list
for o in stringList do {
s=(string key stringList)
print s " -- " o."Object Text" "\n"
}

delete stringList


Note that in order to get the value of the key, it must be cast to the type of data that will be returned. For the second case where the key is an integer, the same functionality can be written like this:

Module m=current
Object o
Skip intList=create
int i

// Put the objects in the skip list, sorted by the object identifier
for o in m do {
i=o."Absolute Number"
put(intList, i, o)
}

// Get the objects in order, and get the key of the list
for o in intList do {
i=(int key intList)
print i " -- " o."Object Text" "\n"
}

delete intList


In my opinion, skip lists are extremely useful. A practical example can be a program that needs to be able to select a specific object out of a module, and repeat the procedure multiple times. A program like this can be setup to use a skip list like in example number two. Now given any absolute number of an object, it is a simple call to get the object itself:

int index=123
if(find(intList, index, o)) {
// do something with object number 123
}


Or to check if the object even exists:

int index=123
if(!find(intList, index)) warningBox "Object " index " does not exist!"


This is probably more information than you were asking for. I was trying to answer two questions at once!

-Dennis
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 1 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.