![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
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 |
![]() |
![]()
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
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. |
|
![]() |
|
![]() |
|
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 |
|
![]() |
Telelogic DOORS
» DXL Exchange
»
Skip lists - extracting key/data pairs
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.