digitalmars.D - LinkedList and Deque API in DCollections
- d coder (18/18) Jun 21 2012 Greetings
- travert phare.normalesup.org (Christophe Travert) (2/24) Jun 21 2012 Did you try : list.insert(list.begin, value);
- d coder (7/8) Jun 21 2012 Thanks. But I believe append and prepend are too common use-cases to be
- travert phare.normalesup.org (Christophe Travert) (7/22) Jun 21 2012 auto append(T, V)(ref T t, V value)
- d coder (4/10) Jun 21 2012 Thanks Christophe. I think you are relying on UFCS here.
- Steven Schveighoffer (9/20) Jun 25 2012 No, if you want to use those asserts, build dcollections with debug flag...
- Steven Schveighoffer (5/6) Jun 25 2012 Should have said "without release flag", you don't need to build with
- d coder (4/8) Jun 21 2012 Ok I think asserts are fine since these would be taken out and the libra...
- Steven Schveighoffer (14/33) Jun 25 2012 This list is fine, you can also create tickets for the TRAC instance for...
Greetings I do not know if this email belongs to this list or not. It is about a package available at dsource. Let me know if I should be posting such emails elsewhere. I need an implementation of Doubly Linked list and Deque. Since the std.container library does not support these containers yet, I am trying to use these from DCollections library available on DSource here http://www.dsource.org/projects/dcollections . I am using the D2 branch of this library. Now the issue is, I could not find any API for adding elements to the beginning of the LinkList. In the documentation (which is there for D1 version) I see methods like append and prepend, but I do not think these are implemented in the D2 version of the library. And I see that for Deque, only prepend is implemented, there is no append. Also it is not clear to me if the "add" method could be used to append elements on the back of the LinkList or Deque collection. Thanks and Regards - Puneet
Jun 21 2012
d coder , dans le message (digitalmars.D:170392), a écrit :--f46d04083de73dc5ab04c2fb032c Content-Type: text/plain; charset=ISO-8859-1 Greetings I do not know if this email belongs to this list or not. It is about a package available at dsource. Let me know if I should be posting such emails elsewhere. I need an implementation of Doubly Linked list and Deque. Since the std.container library does not support these containers yet, I am trying to use these from DCollections library available on DSource here http://www.dsource.org/projects/dcollections . I am using the D2 branch of this library. Now the issue is, I could not find any API for adding elements to the beginning of the LinkList. In the documentation (which is there for D1 version) I see methods like append and prepend, but I do not think these are implemented in the D2 version of the library. And I see that for Deque, only prepend is implemented, there is no append. Also it is not clear to me if the "add" method could be used to append elements on the back of the LinkList or Deque collection.Did you try : list.insert(list.begin, value);
Jun 21 2012
Did you try : list.insert(list.begin, value);Thanks. But I believe append and prepend are too common use-cases to be ignored. Also, I see that "assert(some-expression)" has been used at a lot of places in the code of the libraries. Since these libraries are built with -release option, should these assert statements not be replaced by "enforce"? Regards - Puneet
Jun 21 2012
d coder , dans le message (digitalmars.D:170396), a écrit :--e0cb4efe2a2821373604c2fc4a15 Content-Type: text/plain; charset=ISO-8859-1auto append(T, V)(ref T t, V value) { return t.insert(t.begin, value); } should do the trick. (you may add a guard to make sure T is a container)Did you try : list.insert(list.begin, value);Thanks. But I believe append and prepend are too common use-cases to be ignored. Also, I see that "assert(some-expression)" has been used at a lot of places in the code of the libraries. Since these libraries are built with -release option, should these assert statements not be replaced by "enforce"?
Jun 21 2012
auto append(T, V)(ref T t, V value) { return t.insert(t.begin, value); } should do the trick. (you may add a guard to make sure T is a container)Thanks Christophe. I think you are relying on UFCS here. So cool. Regards - Puneet
Jun 21 2012
On Thu, 21 Jun 2012 10:24:57 -0400, d coder <dlang.coder gmail.com> wrote:No, if you want to use those asserts, build dcollections with debug flag. It's quite impossible for me to tell whether you want the asserts or not. There isn't currently an easy way to build without -release with my build scripts, I should add that. Also note that in most cases, you will not have to do this -- all dcollections objects are templates, which means they get instantiated in non-release mode if that's how you compile your code that uses it. -SteveDid you try : list.insert(list.begin, value);Thanks. But I believe append and prepend are too common use-cases to be ignored. Also, I see that "assert(some-expression)" has been used at a lot of places in the code of the libraries. Since these libraries are built with -release option, should these assert statements not be replaced by "enforce"?
Jun 25 2012
On Mon, 25 Jun 2012 09:44:12 -0400, Steven Schveighoffer <schveiguy yahoo.com> wrote:No, if you want to use those asserts, build dcollections with debug flag.Should have said "without release flag", you don't need to build with debug flag. -Steve
Jun 25 2012
Also, I see that "assert(some-expression)" has been used at a lot of places in the code of the libraries. Since these libraries are built with -release option, should these assert statements not be replaced by "enforce"?Ok I think asserts are fine since these would be taken out and the library becomes more efficient without these checks. Please ignore. Regards - Puneet
Jun 21 2012
On Thu, 21 Jun 2012 08:53:33 -0400, d coder <dlang.coder gmail.com> wrote:Greetings I do not know if this email belongs to this list or not. It is about a package available at dsource. Let me know if I should be posting such emails elsewhere.This list is fine, you can also create tickets for the TRAC instance for dcollections. http://www.dsource.org/projects/dcollections/newticketI need an implementation of Doubly Linked list and Deque. Since the std.container library does not support these containers yet, I am trying to use these from DCollections library available on DSource here http://www.dsource.org/projects/dcollections . I am using the D2 branch of this library. Now the issue is, I could not find any API for adding elements to the beginning of the LinkList. In the documentation (which is there for D1 version) I see methods like append and prepend, but I do not think these are implemented in the D2 version of the library. And I see that for Deque, only prepend is implemented, there is no append.prepend should be implemented for LinkedList, that is an oversight. Yes, you can use insert(ll.begin, elem), but the API should be consistent across containers.Also it is not clear to me if the "add" method could be used to append elements on the back of the LinkList or Deque collection.Append is actually implemented via add. For lists, add always adds to the end (including ArrayList, LinkList and Deque). This is not a requirement of the interface, but it happens to be how it's implemented for all the current containers. This should be noted in the docs (which I profusely apologize for not having available). I should make an alias to append from add. -Steve
Jun 25 2012