• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Digital Implementation
  3. Printing common elements between 2 collections

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 91
  • Views 14658
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Printing common elements between 2 collections

abhishektheone
abhishektheone over 11 years ago

Hi,

 Is there a quick way to print all the common elements between 2 collections. Right now I am doing to usual loop method of comparison. Please let me know if there is an easier/faster way.

 

Regards, 

  • Cancel
  • BobD
    BobD over 11 years ago

    Not that I know of, though I've had interest in doing the same for TCL lists.

    There's a script called "userListUtilities.tcl" in the gifts dir that might be useful. It contains a proc called "userIntersectLists" that takes 2 lists and finds the common elements. If you converted the collections to lists you could use it (or perhaps modify it for your use?).

    For example - say I have a design with 2 instance: i0 and i1

    encounter 2> set a [get_cells i*]
    0x25 

    encounter 8> set b [get_cells i1]                                        
    0x27 

    Collection a contains i0 and i1, and collection "b" contains just i1:

    encounter 10> get_object_name $a
    i0 i1

    encounter 11> get_object_name $b
    i1 

    Then you could use this proc to interest them (which is probably what you've already written but perhaps a little more fast-running): 

    proc userIntersectLists args {
      set res {}
      foreach element [lindex $args 0] {
        set found 1
        foreach list [lrange $args 1 end] {
          if {[lsearch -exact $list $element] < 0} {
           set found 0; break
          }
        }
      if {$found} {lappend res $element}
      }
      set res
    } 

    encounter 9> userIntersectLists [get_object_name $a] [get_object_name $b]
    i1

    We've discussed providing more list manipulation in the tool and this is a good example of where that would be helpful. We have pretty cool capabilities for shape manipulation with dbShape but basic TCL lists are, perhaps ironically, harder to work with at the moment.

    Hope this helps,
    Bob 

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • abhishektheone
    abhishektheone over 11 years ago
    Thanks Bob, This method is definitely fast. Regards, Abhishek
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information