digitalmars.D.learn - Example of filtering a Linked List that hold a custom class (Tango)
- JJDuck (7/7) Jun 05 2014 let say I have a Linked List(tango) that holds custom class and
- Justin Whear (7/15) Jun 05 2014 Using Phobos this should work for any container type with a range
let say I have a Linked List(tango) that holds custom class and how do I filter the LinkedList to extract the items that I want according to a particular field (a integer field) from my custom class? Is it easier to do it using phobos' Array? If it does, care to have an example on Phobos too? Thanks a lot
Jun 05 2014
On Thu, 05 Jun 2014 17:50:37 +0000, JJDuck wrote:let say I have a Linked List(tango) that holds custom class and how do I filter the LinkedList to extract the items that I want according to a particular field (a integer field) from my custom class? Is it easier to do it using phobos' Array? If it does, care to have an example on Phobos too? Thanks a lotUsing Phobos this should work for any container type with a range interface: // Using a singly-linked list, but any container should work (MyClass[], RedBlackTree!MyClass, etc.) SList!MyClass slist = ... auto filtered = objs.filter!(o => o.myfield = 7);
Jun 05 2014