gnucap-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnucap-devel] Re: gnucap-0.32


From: Al Davis
Subject: [Gnucap-devel] Re: gnucap-0.32
Date: Wed, 18 Dec 2002 17:35:35 -0700

On Wednesday 18 December 2002 12:57 pm, xhecs wrote:
> what does this line do?
>
> CARD_LIST::putbefore =
>               CARD_LIST::fat_iterator(&(CARD_LIST::card_list),
>                                   CARD_LIST::card_list.end())


CARD_LIST::putbefore keeps track of where things are being added.

It is a static member of CARD_LIST, because most circuits have more 
than one CARD_LIST.  Gnucap does not flatten circuits like Spice does.

Think of it as a pointer to where to add the next component.

In C++, an "iterator" is like a smart pointer.  You treat it like a 
pointer.  It actually behaves the way you would like pointers to 
behave.  It is used to iterate over a container.

In C, you can use a pointer to traverse an array.  This is familiar to 
all C programmers.  In C++, iterators let you traverse linked lists (or 
any container) in the same way, with identical syntax.

A "fat_iterator" (in Gnucap) is an extended form of an iterator, that 
also contains information on which container it belongs to.



CARD_LIST::card_list is the root list for storing the circuit.  Think 
of it as a many-branched tree, where the nodes of the tree are lists.




CARD_LIST::fat_iterator is a class.  Using a class name like a function 
call means it is being used as a constructor.  In this case, it 
constructs a fat_iterator pointing to the end of the root list, then 
assigns it to CARD_LIST::putbefore.


So, in one line ....

That line of code sets the insert point, so when you add components 
they are added to the end of the root circuit.


al.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]