Search Results

Search found 33873 results on 1355 pages for 'linked list'.

Page 8/1355 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Origin of common list-processing function names

    - by Heatsink
    Some higher-order functions for operating on lists or arrays have been repeatedly adopted or reinvented. The functions map, fold[l|r], and filter are found together in several programming languages, such as Scheme, ML, and Python, that don't seem to have a common ancestor. I'm going with these three names to keep the question focused. To show that the names are not universal, here is a sampling of names for equivalent functionality in other languages. C++ has transform instead of map and remove_if instead of filter (reversing the meaning of the predicate). Lisp has mapcar instead of map, remove-if-not instead of filter, and reduce instead of fold (Some modern Lisp variants have map but this appears to be a derived form.) C# uses Select instead of map and Where instead of filter. C#'s names came from SQL via LINQ, and despite the name changes, their functionality was influenced by Haskell, which was itself influenced by ML. The names map, fold, and filter are widespread, but not universal. This suggests that they were borrowed from an influential source into other contemporary languages. Where did these function names come from?

    Read the article

  • Oracle 11g ??? – HM(Hang Manager)??

    - by Allen Gao
    Normal 0 7.8 ? 0 2 false false false EN-US ZH-CN X-NONE MicrosoftInternetExplorer4 DefSemiHidden="true" DefQFormat="false" DefPriority="99" LatentStyleCount="267" UnhideWhenUsed="false" QFormat="true" Name="Normal"/ UnhideWhenUsed="false" QFormat="true" Name="heading 1"/ UnhideWhenUsed="false" QFormat="true" Name="Title"/ UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/ UnhideWhenUsed="false" QFormat="true" Name="Strong"/ UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/ UnhideWhenUsed="false" Name="Table Grid"/ UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/ UnhideWhenUsed="false" Name="Light Shading"/ UnhideWhenUsed="false" Name="Light List"/ UnhideWhenUsed="false" Name="Light Grid"/ UnhideWhenUsed="false" Name="Medium Shading 1"/ UnhideWhenUsed="false" Name="Medium Shading 2"/ UnhideWhenUsed="false" Name="Medium List 1"/ UnhideWhenUsed="false" Name="Medium List 2"/ UnhideWhenUsed="false" Name="Medium Grid 1"/ UnhideWhenUsed="false" Name="Medium Grid 2"/ UnhideWhenUsed="false" Name="Medium Grid 3"/ UnhideWhenUsed="false" Name="Dark List"/ UnhideWhenUsed="false" Name="Colorful Shading"/ UnhideWhenUsed="false" Name="Colorful List"/ UnhideWhenUsed="false" Name="Colorful Grid"/ UnhideWhenUsed="false" Name="Light Shading Accent 1"/ UnhideWhenUsed="false" Name="Light List Accent 1"/ UnhideWhenUsed="false" Name="Light Grid Accent 1"/ UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/ UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/ UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/ UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/ UnhideWhenUsed="false" QFormat="true" Name="Quote"/ UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/ UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/ UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/ UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/ UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/ UnhideWhenUsed="false" Name="Dark List Accent 1"/ UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/ UnhideWhenUsed="false" Name="Colorful List Accent 1"/ UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/ UnhideWhenUsed="false" Name="Light Shading Accent 2"/ UnhideWhenUsed="false" Name="Light List Accent 2"/ UnhideWhenUsed="false" Name="Light Grid Accent 2"/ UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/ UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/ UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/ UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/ UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/ UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/ UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/ UnhideWhenUsed="false" Name="Dark List Accent 2"/ UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/ UnhideWhenUsed="false" Name="Colorful List Accent 2"/ UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/ UnhideWhenUsed="false" Name="Light Shading Accent 3"/ UnhideWhenUsed="false" Name="Light List Accent 3"/ UnhideWhenUsed="false" Name="Light Grid Accent 3"/ UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/ UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/ UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/ UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/ UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/ UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/ UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/ UnhideWhenUsed="false" Name="Dark List Accent 3"/ UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/ UnhideWhenUsed="false" Name="Colorful List Accent 3"/ UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/ UnhideWhenUsed="false" Name="Light Shading Accent 4"/ UnhideWhenUsed="false" Name="Light List Accent 4"/ UnhideWhenUsed="false" Name="Light Grid Accent 4"/ UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/ UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/ UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/ UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/ UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/ UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/ UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/ UnhideWhenUsed="false" Name="Dark List Accent 4"/ UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/ UnhideWhenUsed="false" Name="Colorful List Accent 4"/ UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/ UnhideWhenUsed="false" Name="Light Shading Accent 5"/ UnhideWhenUsed="false" Name="Light List Accent 5"/ UnhideWhenUsed="false" Name="Light Grid Accent 5"/ UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/ UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/ UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/ UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/ UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/ UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/ UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/ UnhideWhenUsed="false" Name="Dark List Accent 5"/ UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/ UnhideWhenUsed="false" Name="Colorful List Accent 5"/ UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/ UnhideWhenUsed="false" Name="Light Shading Accent 6"/ UnhideWhenUsed="false" Name="Light List Accent 6"/ UnhideWhenUsed="false" Name="Light Grid Accent 6"/ UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/ UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/ UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/ UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/ UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/ UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/ UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/ UnhideWhenUsed="false" Name="Dark List Accent 6"/ UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/ UnhideWhenUsed="false" Name="Colorful List Accent 6"/ UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/ UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/ UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/ UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/ UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/ UnhideWhenUsed="false" QFormat="true" Name="Book Title"/ /* Style Definitions */ table.MsoNormalTable {mso-style-name:????; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.5pt; mso-bidi-font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:??; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-font-kerning:1.0pt;} ??????????oracle 11g ???—hang ???(Hang Manager) ???????????,HM ??RAC ??????? ?????????????,??????????/?? hang???????hang???,????,??????????? ??(cycle)?????hang, ???????,???????? ?????(blocker) ?????????????????????,???????,?????blocker ????????(immediate blocker)??????(root blocker)??root blocker ?????????????? 2.1 ???????????,??????,????????????? 2.2 ????????????????????(??:??I/O),??????,????????????????,?????????,????????????? ??????????, oracle??????????? ???????????11g RAC???? hang????hang ?????????? 1.?????????????hang analyze dump ??? 2.????hang analyze dump??(?????) 3. ??????dump??,??????????hang? 4. ??????????hang??? ???,??????????????? ??1: ORACLE ??????????,????? hang analysis cache,???????hang analyze dump i?????????????????????????? ??2:oracle ?????hang analyze ??,??,HM?????RAC??????,hang analyze??????????????,??????dump ????????DIA0(?????11g????)???????3????????hang analyze dump, ?10 ???????hang analyze dump? ??3:??,????????hang analyze dump ??,??,??????????????DIA0??,???????hang ?????,??RAC???,??hang????????????????,??????????DIA0 ????master,???????????????????11g??,?????????DIA0?????HM?master?????,?????????????,?(master)DIA0 ???????????????????? ??hang???,HM????????????,?HM?????hang analyze dump(?30???????,????????)?,??????????????????(???????open chain),????????????????(??,???????????),??,???????,?????????hang??????????????,?????????????????,???????????(open chain)??????,???????????????????hang.??,????(dead lock)????,????????,???????????????????????????? Normal 0 7.8 ? 0 2 false false false EN-US ZH-CN X-NONE MicrosoftInternetExplorer4 DefSemiHidden="true" DefQFormat="false" DefPriority="99" LatentStyleCount="267" UnhideWhenUsed="false" QFormat="true" Name="Normal"/ UnhideWhenUsed="false" QFormat="true" Name="heading 1"/ UnhideWhenUsed="false" QFormat="true" Name="Title"/ UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/ UnhideWhenUsed="false" QFormat="true" Name="Strong"/ UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/ UnhideWhenUsed="false" Name="Table Grid"/ UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/ UnhideWhenUsed="false" Name="Light Shading"/ UnhideWhenUsed="false" Name="Light List"/ UnhideWhenUsed="false" Name="Light Grid"/ UnhideWhenUsed="false" Name="Medium Shading 1"/ UnhideWhenUsed="false" Name="Medium Shading 2"/ UnhideWhenUsed="false" Name="Medium List 1"/ UnhideWhenUsed="false" Name="Medium List 2"/ UnhideWhenUsed="false" Name="Medium Grid 1"/ UnhideWhenUsed="false" Name="Medium Grid 2"/ UnhideWhenUsed="false" Name="Medium Grid 3"/ UnhideWhenUsed="false" Name="Dark List"/ UnhideWhenUsed="false" Name="Colorful Shading"/ UnhideWhenUsed="false" Name="Colorful List"/ UnhideWhenUsed="false" Name="Colorful Grid"/ UnhideWhenUsed="false" Name="Light Shading Accent 1"/ UnhideWhenUsed="false" Name="Light List Accent 1"/ UnhideWhenUsed="false" Name="Light Grid Accent 1"/ UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/ UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/ UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/ UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/ UnhideWhenUsed="false" QFormat="true" Name="Quote"/ UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/ UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/ UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/ UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/ UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/ UnhideWhenUsed="false" Name="Dark List Accent 1"/ UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/ UnhideWhenUsed="false" Name="Colorful List Accent 1"/ UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/ UnhideWhenUsed="false" Name="Light Shading Accent 2"/ UnhideWhenUsed="false" Name="Light List Accent 2"/ UnhideWhenUsed="false" Name="Light Grid Accent 2"/ UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/ UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/ UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/ UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/ UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/ UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/ UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/ UnhideWhenUsed="false" Name="Dark List Accent 2"/ UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/ UnhideWhenUsed="false" Name="Colorful List Accent 2"/ UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/ UnhideWhenUsed="false" Name="Light Shading Accent 3"/ UnhideWhenUsed="false" Name="Light List Accent 3"/ UnhideWhenUsed="false" Name="Light Grid Accent 3"/ UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/ UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/ UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/ UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/ UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/ UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/ UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/ UnhideWhenUsed="false" Name="Dark List Accent 3"/ UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/ UnhideWhenUsed="false" Name="Colorful List Accent 3"/ UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/ UnhideWhenUsed="false" Name="Light Shading Accent 4"/ UnhideWhenUsed="false" Name="Light List Accent 4"/ UnhideWhenUsed="false" Name="Light Grid Accent 4"/ UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/ UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/ UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/ UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/ UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/ UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/ UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/ UnhideWhenUsed="false" Name="Dark List Accent 4"/ UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/ UnhideWhenUsed="false" Name="Colorful List Accent 4"/ UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/ UnhideWhenUsed="false" Name="Light Shading Accent 5"/ UnhideWhenUsed="false" Name="Light List Accent 5"/ UnhideWhenUsed="false" Name="Light Grid Accent 5"/ UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/ UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/ UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/ UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/ UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/ UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/ UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/ UnhideWhenUsed="false" Name="Dark List Accent 5"/ UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/ UnhideWhenUsed="false" Name="Colorful List Accent 5"/ UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/ UnhideWhenUsed="false" Name="Light Shading Accent 6"/ UnhideWhenUsed="false" Name="Light List Accent 6"/ UnhideWhenUsed="false" Name="Light Grid Accent 6"/ UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/ UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/ UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/ UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/ UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/ UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/ UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/ UnhideWhenUsed="false" Name="Dark List Accent 6"/ UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/ UnhideWhenUsed="false" Name="Colorful List Accent 6"/ UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/ UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/ UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/ UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/ UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/ UnhideWhenUsed="false" QFormat="true" Name="Book Title"/ /* Style Definitions */ table.MsoNormalTable {mso-style-name:????; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.5pt; mso-bidi-font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:??; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-font-kerning:1.0pt;} ??4: ???hang??????,??hang???????????????HM ??,????hang?????????????,??HM???????hang. 1. ??????????????????hang??,??:asm?????? 2. ????????????,??:TX?? 3. ???? 4. ???????????:???????“log file switch ”(?????????????????filesystem??????????HM????????,hang??????????)? ??,hang?HM???????,??HM?????????? ???HM???????,??????????????????,?????????oracle ???????,?????????crash???,HM???hang???,??????????????????"_hang_resolution_scope" ???,??????????off(???,????HM?????hang),process(??HM??????,??????????????),instance(??HM??????,??????????????????????????)? ??,????HM ????????trace ?????????? ??: _hang_resolution=TRUE ?? FALSE?????????HM????hang? _hang_resolution_scope=OFF,PORCESS?? INSTANCE?????????HM???????? _hang_detection= <number>? HM??hang?????,????30(?)? ??????????,???????????,??“Oracle 11g ??? – HM(Hang Manager)??"?

    Read the article

  • adding a node to a linked list.

    - by sil3nt
    Hi there, ive been given the following code, And im just wondering, what does *&listpointer mean in the argument of the addnode function? struct Node { int accnumber; float balance; Node *next; }; Node *A, *B; int main() { A = NULL; B = NULL; AddNode(A, 123, 99.87); AddNode(B, 789, 52.64); } void AddNode(Node * & listpointer, int a, float b) { // add a new node to the FRONT of the list Node *temp; temp = new Node; temp->accnumber = a; temp->balance = b; temp->next = listpointer; listpointer = temp; }

    Read the article

  • A linked list with multiple heads in Java

    - by Emile
    Hi, I have a list in which I'd like to keep several head pointers. I've tried to create multiple ListIterators on the same list but this forbid me to add new elements in my list... (see Concurrent Modification exception). I could create my own class but I'd rather use a built-in implementation ;) To be more specific, here is an inefficient implementation of two basic operations and the one wich doesn't work : class MyList <E { private int[] _heads; private List<E _l; public MyList ( int nbHeads ) { _heads = new int[nbHeads]; _l = new LinkedList<E(); } public void add ( E e ) { _l.add(e); } public E next ( int head ) { return _l.get(_heads[head++]); // ugly } } class MyList <E { private Vector<ListIterator<E _iters; private List<E _l; public MyList ( int nbHeads ) { _iters = new Vector<ListIterator<E(nbHeads); _l = new LinkedList<E(); for( ListIterator<E iter : _iters ) iter = _l.listIterator(); } public void add ( E e ) { _l.add(e); } public E next ( int head ) { // ConcurrentModificationException because of the add() return _iters.get(head).next(); } } Emile

    Read the article

  • pointer and reference question (linked lists)

    - by sil3nt
    Hi there, I have the following code struct Node { int accnumber; float balance; Node *next; }; Node *A, *B; int main() { A = NULL; B = NULL; AddNode(A, 123, 99.87); AddNode(B, 789, 52.64); etc… } void AddNode(Node * & listpointer, int a, float b) { // add a new node to the FRONT of the list Node *temp; temp = new Node; temp->accnumber = a; temp->balance = b; temp->next = listpointer; listpointer = temp; } in this here void AddNode(Node * & listpointer, int a, float b) { what does *& listpointer mean exactly.

    Read the article

  • Removing a node from a linked list

    - by lost_with_coding
    I would like to create a delete_node function that deletes the node at the location in the list as a count from the first node. So far this is the code I have: class node: def __init__(self): self.data = None # contains the data self.next = None # contains the reference to the next node class linked_list: def __init__(self): self.cur_node = None def add_node(self, data): new_node = node() # create a new node new_node.data = data new_node.next = self.cur_node # link the new node to the 'previous' node. self.cur_node = new_node # set the current node to the new one. def list_print(self): node = ll.cur_node while node: print node.data node = node.next def delete_node(self,location): node = ll.cur_node count = 0 while count != location: node = node.next count+=1 delete node ll = linked_list() ll.add_node(1) ll.add_node(2) ll.add_node(3) ll.list_print()

    Read the article

  • Using list comprehension in Python to do something similar to zip()?

    - by jamieb
    I'm a Python newbie and one of the things I am trying to do is wrap my head around list comprehension. I can see that it's a pretty powerful feature that's worth learning. cities = ['Chicago', 'Detroit', 'Atlanta'] airports = ['ORD', 'DTW', 'ATL'] print zip(cities,airports) [('Chicago', 'ORD'), ('Detroit', 'DTW'), ('Atlanta', 'ATL')] How do I use list comprehension so I can get the results as a series of lists within a list, rather than a series of tuples within a list? [['Chicago', 'ORD'], ['Detroit', 'DTW'], ['Atlanta', 'ATL']] (I realize that dictionaries would probably be more appropriate in this situation, but I'm just trying to understand lists a bit better). Thanks!

    Read the article

  • C# / this. and List<T>

    - by user3533030
    I am having trouble understanding how to initialize a List of objects and use it with methods inside of a class. I understand the mechanics of the List, but not how to initialize it inside a method and use it later. For example, I want to have a class that creates the List when it is constructed. Then, I want to use a method of that class to add elements to the list. The elements in the list are objects defined by the SolidWorks API. So, to construct the List, I used... public class ExportPoints : Exporter { public List<SldWorks.SketchPoint> listOfSketchPoints; public ExportPoints(SldWorks.SldWorks swApp, string nameSuffix) : base(swApp, nameSuffix) { List<SldWorks.SketchPoint> listOfSketchPoints = new List<SldWorks.SketchPoint>(); } public void createListOfFreePoints() { try { [imagine more code here] this.listOfSketchPoints.Add(pointTest); } catch (Exception e) { Debug.Print(e.ToString()); return; } } This fails during execution as if the listOfSketchPoints was never initialized as a List. So, I tried a hack and this worked: public ExportPoints(SldWorks.SldWorks swApp, string nameSuffix) : base(swApp, nameSuffix) { List<SldWorks.SketchPoint> listOfSketchPoints = new List<SldWorks.SketchPoint>(); this.listOfSketchPoints = listOfSketchPoints; } This approach creates the behavior that I want. However, it seems that I lack some understanding as to why this is necessary. Shouldn't it be possible to "initialize" a List that is a property of your object with a constructor? Why would you need to create the list, then assign the pointer of that new List to your property?

    Read the article

  • .NET List Thread-Safe Implementation Suggestion needed

    - by Bamboo
    .Net List class isn't thread safe. I hope to achieve the minimal lock needed and yet still fulfilling the requirement such that as for reading, phantom record is allowed, and for writing, they must be thread-safe so there won't be any lost updates. So I have something like public static List<string> list = new List<string>(); In Methods that have **List.Add**/**List.Remove** , I always lock to assure thread safety lock (lockHelper) { list.Add(obj); or list.Remove(obj); } In Methods that requires **List Reading** I don't care about phantom record so I go ahead to read without any locking. In this case. Return a bool by checking whether a string had been added. if (list.Count() != 0) { return list.Contains("some string") } All I did was locking write accesses, and allow read accesses to go through without any locking. Is my thread safety idea valid? I understand there is List size expansion. Will it be ok? My guess is that when a List is expanding, it may uses a temp. list. This is ok becasue the temp list size will always have a boundary, and .Net class is well implemented, ie. there shouldn't be any indexOutOfBound or circular reference problems when reading was caught in updates.

    Read the article

  • Why is this removing all elements from my LinkedList?

    - by Brian
    Why is my remove method removing every element from my Doubly Linked List? If I take out that if/else statements then I can successfully remove middle elements, but elements at the head or tail of the list still remain. However, I added the if/else statements to take care of elements at the head and tail, unfortunately this method now removes every element in my list. What am I do wrong? public void remove(int n) { LinkEntry<E> remove_this = new LinkEntry<E>(); //if nothing comes before remove_this, set the head to equal the element after remove_this if (remove_this.previous == null) head = remove_this.next; //otherwise set the element before remove_this equal to the element after remove_this else remove_this.previous.next = remove_this.next; //if nothing comes after remove_this, set the tail equal to the element before remove_this if (remove_this.next == null) tail = remove_this.previous; //otherwise set the next element's previous pointer to the element before remove_this else remove_this.next.previous = remove_this.previous; //if remove_this is located in the middle of the list, enter this loop until it is //found, then remove it, closing the gap afterwards. int i = 0; for (remove_this = head; remove_this != null; remove_this = remove_this.next) { //if i == n, stop and delete 'remove_this' from the list if (i == n) { //set the previous element's next to the element that comes after remove_this remove_this.previous.next = remove_this.next; //set the element after remove_this' previous pointer to the element before remove_this remove_this.next.previous = remove_this.previous; break; } //if i != n, keep iterating through the list i++; } }

    Read the article

  • EM12c: Using the LIST verb in emcli

    - by SubinDaniVarughese
    Many of us who use EM CLI to write scripts and automate our daily tasks should not miss out on the new list verb released with Oracle Enterprise Manager 12.1.0.3.0. The combination of list and Jython based scripting support in EM CLI makes it easier to achieve automation for complex tasks with just a few lines of code. Before I jump into a script, let me highlight the key attributes of the list verb and why it’s simply excellent! 1. Multiple resources under a single verb:A resource can be set of users or targets, etc. Using the list verb, you can retrieve information about a resource from the repository database.Here is an example which retrieves the list of administrators within EM.Standard mode$ emcli list -resource="Administrators" Interactive modeemcli>list(resource="Administrators")The output will be the same as standard mode.Standard mode$ emcli @myAdmin.pyEnter password :  ******The output will be the same as standard mode.Contents of myAdmin.py scriptlogin()print list(resource="Administrators",jsonout=False).out()To get a list of all available resources use$ emcli list -helpWith every release of EM, more resources are being added to the list verb. If you have a resource which you feel would be valuable then go ahead and contact Oracle Support to log an enhancement request with product development. Be sure to say how the resource is going to help improve your daily tasks. 2. Consistent Formatting:It is possible to format the output of any resource consistently using these options:  –column  This option is used to specify which columns should be shown in the output. Here is an example which shows the list of administrators and their account status$ emcli list -resource="Administrators" -columns="USER_NAME,REPOS_ACCOUNT_STATUS" To get a list of columns in a resource use:$ emcli list -resource="Administrators" -help You can also specify the width of the each column. For example, here the column width of user_type is set to 20 and department to 30. $ emcli list -resource=Administrators -columns="USER_NAME,USER_TYPE:20,COST_CENTER,CONTACT,DEPARTMENT:30"This is useful if your terminal is too small or you need to fine tune a list of specific columns for your quick use or improved readability.  –colsize  This option is used to resize column widths.Here is the same example as above, but using -colsize to define the width of user_type to 20 and department to 30.$ emcli list -resource=Administrators -columns="USER_NAME,USER_TYPE,COST_CENTER,CONTACT,DEPARTMENT" -colsize="USER_TYPE:20,DEPARTMENT:30" The existing standard EMCLI formatting options are also available in list verb. They are: -format="name:pretty" | -format="name:script” | -format="name:csv" | -noheader | -scriptThere are so many uses depending on your needs. Have a look at the resources and columns in each resource. Refer to the EMCLI book in EM documentation for more information.3. Search:Using the -search option in the list verb makes it is possible to search for a specific row in a specific column within a resource. This is similar to the sqlplus where clause. The following operators are supported:           =           !=           >           <           >=           <=           like           is (Must be followed by null or not null)Here is an example which searches for all EM administrators in the marketing department located in the USA.$emcli list -resource="Administrators" -search="DEPARTMENT ='Marketing'" -search="LOCATION='USA'" Here is another example which shows all the named credentials created since a specific date.  $emcli list -resource=NamedCredentials -search="CredCreatedDate > '11-Nov-2013 12:37:20 PM'"Note that the timestamp has to be in the format DD-MON-YYYY HH:MI:SS AM/PM Some resources need a bind variable to be passed to get output. A bind variable is created in the resource and then referenced in the command. For example, this command will list all the default preferred credentials for target type oracle_database.Here is an example$ emcli list -resource="PreferredCredentialsDefault" -bind="TargetType='oracle_database'" -colsize="SetName:15,TargetType:15" You can provide multiple bind variables. To verify if a column is searchable or requires a bind variable, use the –help option. Here is an example:$ emcli list -resource="PreferredCredentialsDefault" -help 4. Secure accessWhen list verb collects the data, it only displays content for which the administrator currently logged into emcli, has access. For example consider this usecase:AdminA has access only to TargetA. AdminA logs into EM CLIExecuting the list verb to get the list of all targets will only show TargetA.5. User defined SQLUsing the –sql option, user defined sql can be executed. The SQL provided in the -sql option is executed as the EM user MGMT_VIEW, which has read-only access to the EM published MGMT$ database views in the SYSMAN schema. To get the list of EM published MGMT$ database views, go to the Extensibility Programmer's Reference book in EM documentation. There is a chapter about Using Management Repository Views. It’s always recommended to reference the documentation for the supported MGMT$ database views.  Consider you are using the MGMT$ABC view which is not in the chapter. During upgrade, it is possible, since the view was not in the book and not supported, it is likely the view might undergo a change in its structure or the data in it. Using a supported view ensures that your scripts using -sql will continue working after upgrade.Here’s an example  $ emcli list -sql='select * from mgmt$target' 6. JSON output support    JSON (JavaScript Object Notation) enables data to be displayed in a collection of name/value pairs. There is lot of reading material about JSON on line for more information.As an example, we had a requirement where an EM administrator had many 11.2 databases in their test environment and the developers had requested an Administrator to change the lifecycle status from Test to Production which meant the admin had to go to the EM “All targets” page and identify the set of 11.2 databases and then to go into each target database page and manually changes the property to Production. Sounds easy to say, but this Administrator had numerous targets and this task is repeated for every release cycle.We told him there is an easier way to do this with a script and he can reuse the script whenever anyone wanted to change a set of targets to a different Lifecycle status. Here is a jython script which uses list and JSON to change all 11.2 database target’s LifeCycle Property value.If you are new to scripting and Jython, I would suggest visiting the basic chapters in any Jython tutorials. Understanding Jython is important to write the logic depending on your usecase.If you are already writing scripts like perl or shell or know a programming language like java, then you can easily understand the logic.Disclaimer: The scripts in this post are subject to the Oracle Terms of Use located here.  1 from emcli import *  2  search_list = ['PROPERTY_NAME=\'DBVersion\'','TARGET_TYPE= \'oracle_database\'','PROPERTY_VALUE LIKE \'11.2%\'']  3 if len(sys.argv) == 2:  4    print login(username=sys.argv[0])  5    l_prop_val_to_set = sys.argv[1]  6      l_targets = list(resource="TargetProperties", search=search_list,   columns="TARGET_NAME,TARGET_TYPE,PROPERTY_NAME")  7    for target in l_targets.out()['data']:  8       t_pn = 'LifeCycle Status'  9      print "INFO: Setting Property name " + t_pn + " to value " +       l_prop_val_to_set + " for " + target['TARGET_NAME']  10      print  set_target_property_value(property_records=      target['TARGET_NAME']+":"+target['TARGET_TYPE']+":"+      t_pn+":"+l_prop_val_to_set)  11  else:  12   print "\n ERROR: Property value argument is missing"  13   print "\n INFO: Format to run this file is filename.py <username>   <Database Target LifeCycle Status Property Value>" You can download the script from here. I could not upload the file with .py extension so you need to rename the file to myScript.py before executing it using emcli.A line by line explanation for beginners: Line  1 Imports the emcli verbs as functions  2 search_list is a variable to pass to the search option in list verb. I am using escape character for the single quotes. In list verb to pass more than one value for the same option, you should define as above comma separated values, surrounded by square brackets.  3 This is an “if” condition to ensure the user does provide two arguments with the script, else in line #15, it prints an error message.  4 Logging into EM. You can remove this if you have setup emcli with autologin. For more details about setup and autologin, please go the EM CLI book in EM documentation.  5 l_prop_val_to_set is another variable. This is the property value to be set. Remember we are changing the value from Test to Production. The benefit of this variable is you can reuse the script to change the property value from and to any other values.  6 Here the output of the list verb is stored in l_targets. In the list verb I am passing the resource as TargetProperties, search as the search_list variable and I only need these three columns – target_name, target_type and property_name. I don’t need the other columns for my task.  7 This is a for loop. The data in l_targets is available in JSON format. Using the for loop, each pair will now be available in the ‘target’ variable.  8 t_pn is the “LifeCycle Status” variable. If required, I can have this also as an input and then use my script to change any target property. In this example, I just wanted to change the “LifeCycle Status”.  9 This a message informing the user the script is setting the property value for dbxyz.  10 This line shows the set_target_property_value verb which sets the value using the property_records option. Once it is set for a target pair, it moves to the next one. In my example, I am just showing three dbs, but the real use is when you have 20 or 50 targets. The script is executed as:$ emcli @myScript.py subin Production The recommendation is to first test the scripts before running it on a production system. We tested on a small set of targets and optimizing the script for fewer lines of code and better messaging.For your quick reference, the resources available in Enterprise Manager 12.1.0.4.0 with list verb are:$ emcli list -helpWatch this space for more blog posts using the list verb and EM CLI Scripting use cases. I hope you enjoyed reading this blog post and it has helped you gain more information about the list verb. Happy Scripting!!Disclaimer: The scripts in this post are subject to the Oracle Terms of Use located here. Stay Connected: Twitter | Facebook | YouTube | Linkedin | Newsletter mt=8">Download the Oracle Enterprise Manager 12c Mobile app

    Read the article

  • print a linear linked list into a table

    - by user1796970
    I am attempting to print some values i have stored into a LLL into a readable table. The data i have stored is the following : DEBBIE STARR F 3 W 1000.00 JOAN JACOBUS F 9 W 925.00 DAVID RENN M 3 H 4.75 ALBERT CAHANA M 3 H 18.75 DOUGLAS SHEER M 5 W 250.00 SHARI BUCHMAN F 9 W 325.00 SARA JONES F 1 H 7.50 RICKY MOFSEN M 6 H 12.50 JEAN BRENNAN F 6 H 5.40 JAMIE MICHAELS F 8 W 150.00 i have stored each firstname, lastname, gender, tenure, payrate, and salary into their own List. And would like to be able to print them out in the same format that they are viewed on the text file i read them in from. i have messed around with a few methods that allow me to traverse and print the Lists, but i end up with ugly output. . . here is my code for the storage of the text file and the format i would like to print out: public class Payroll { private LineWriter lw; private ObjectList output; ListNode input; private ObjectList firstname, lastname, gender, tenure, rate, salary; public Payroll(LineWriter lw) { this.lw = lw; this.firstname = new ObjectList(); this.lastname = new ObjectList(); this.gender = new ObjectList(); this.tenure = new ObjectList(); this.rate = new ObjectList(); this.salary = new ObjectList(); this.output = new ObjectList(); this.input = new ListNode(); } public void readfile() { File file = new File("payfile.txt"); try{ Scanner scanner = new Scanner(file); while(scanner.hasNextLine()) { String line = scanner.nextLine(); Scanner lineScanner = new Scanner(line); lineScanner.useDelimiter("\\s+"); while(lineScanner.hasNext()) { firstname.insert1(lineScanner.next()); lastname.insert1(lineScanner.next()); gender.insert1(lineScanner.next()); tenure.insert1(lineScanner.next()); rate.insert1(lineScanner.next()); salary.insert1(lineScanner.next()); } } }catch(FileNotFoundException e) {e.printStackTrace();} } public void printer(LineWriter lw) { String msg = " FirstName " + " LastName " + " Gender " + " Tenure " + " Pay Rate " + " Salary "; output.insert1(msg); System.out.println(output.getFirst()); System.out.println(" " + firstname.getFirst() + " " + lastname.getFirst() + "\t" + gender.getFirst() + "\t" + tenure.getFirst() + "\t" + rate.getFirst() + "\t" + salary.getFirst()); } }

    Read the article

  • Double Linked List Insertion Sorting Bug

    - by house
    Hello, I have implemented an insertion sort in a double link list (highest to lowest) from a file of 10,000 ints, and output to file in reverse order. To my knowledge I have implemented such a program, however I noticed in the ouput file, a single number is out of place. Every other number is in correct order. The number out of place is a repeated number, but the other repeats of this number are in correct order. Its just strange how this number is incorrectly placed. Also the unsorted number is only 6 places out of sync. I have looked through my program for days now with no idea where the problem lies, so I turn to you for help. Below is the code in question, (side note: can my question be deleted by myself? rather my colleges dont thieve my code, if not how can it be deleted?) void DLLIntStorage::insertBefore(int inValue, node *nodeB) { node *newNode; newNode = new node(); newNode->prev = nodeB->prev; newNode->next = nodeB; newNode->value = inValue; if(nodeB->prev==NULL) { this->front = newNode; } else { nodeB->prev->next = newNode; } nodeB->prev = newNode; } void DLLIntStorage::insertAfter(int inValue, node *nodeB) { node *newNode; newNode = new node(); newNode->next = nodeB->next; newNode->prev = nodeB; newNode->value = inValue; if(nodeB->next == NULL) { this->back = newNode; } else { nodeB->next->prev = newNode; } nodeB->next = newNode; } void DLLIntStorage::insertFront(int inValue) { node *newNode; if(this->front == NULL) { newNode = new node(); this->front = newNode; this->back = newNode; newNode->prev = NULL; newNode->next = NULL; newNode->value = inValue; } else { insertBefore(inValue, this->front); } } void DLLIntStorage::insertBack(int inValue) { if(this->back == NULL) { insertFront(inValue); } else { insertAfter(inValue, this->back); } } ifstream& operator>> (ifstream &in, DLLIntStorage &obj) { int readInt, counter = 0; while(!in.eof()) { if(counter==dataLength) //stops at 10,000 { break; } in >> readInt; if(obj.front != NULL ) { obj.insertion(readInt); } else { obj.insertBack(readInt); } counter++; } return in; } void DLLIntStorage::insertion(int inValue) { node* temp; temp = this->front; if(temp->value >= inValue) { insertFront(inValue); return; } else { while(temp->next!=NULL && temp!=this->back) { if(temp->value >= inValue) { insertBefore(inValue, temp); return; } temp = temp->next; } } if(temp == this->back) { insertBack(inValue); } } Thankyou for your time.

    Read the article

  • Efficient list compacting

    - by Patrik
    Suppose you have a list of unsigned ints. Suppose some elements are equal to 0 and you want to push them back. Currently I use this code (list is a pointer to a list of unsigned ints of size n for (i = 0; i < n; ++i) { if (list[i]) continue; int j; for (j = i + 1; j < n && !list[j]; ++j); int z; for (z = j + 1; z < n && list[z]; ++z); if (j == n) break; memmove(&(list[i]), &(list[j]), sizeof(unsigned int) * (z - j))); int s = z - j + i; for(j = s; j < z; ++j) list[j] = 0; i = s - 1; } Can you think of a more efficient way to perform this task? The snippet is purely theoretical, in the production code, each element of list is a 64 bytes struct EDIT: I'll post my solution. Many thanks to Jonathan Leffler. void RemoveDeadParticles(int * list, int * n) { int i, j = *n - 1; for (; j >= 0 && list[j] == 0; --j); for (i = 0; i < j; ++i) { if (list[i]) continue; memcpy(&(list[i]), &(list[j]), sizeof(int)); list[j] = 0; for (; j >= 0 && list[j] == 0; --j); if (i == j) break; } *n = i + 1; }

    Read the article

  • this is my first time asking here, I wanted to create a linked list while sorting it thanks

    - by user2738718
    package practise; public class Node { // node contains data and next public int data; public Node next; //constructor public Node (int data, Node next){ this.data = data; this.next = next; } //list insert method public void insert(Node list, int s){ //case 1 if only one element in the list if(list.next == null && list.data > s) { Node T = new Node(s,list); } else if(list.next == null && list.data < s) { Node T = new Node(s,null); list.next = T; } //case 2 if more than 1 element in the list // 3 elements present I set prev to null and curr to list then performed while loop if(list.next.next != null) { Node curr = list; Node prev = null; while(curr != null) { prev = curr; curr = curr.next; if(curr.data > s && prev.data < s){ Node T = new Node(s,curr); prev.next = T; } } // case 3 at the end checks for the data if(prev.data < s){ Node T = new Node(s,null); prev.next = T; } } } } // this is a hw problem, i created the insert method so i can check and place it in the correct order so my list is sorted This is how far I got, please correct me if I am wrong, I keep inserting node in the main method, Node root = new Node(); and root.insert() to add.

    Read the article

  • Is this good code? Linked List Stack Implementation

    - by Quik Tester
    I have used the following code for a stack implementation. The top keeps track of the topmost node of the stack. Now since top is a data member of the node function, each node created will have a top member, which ideally we wouldn't want. Firstly, is this good approach to coding? Secondly, will making top as static make it a better coding practice? Or should I have a global declaration of top? #include<iostream> using namespace std; class node { int data; node *top; node *link; public: node() { top=NULL; link=NULL; } void push(int x) { node *n=new node; n->data=x; n->link=top; top=n; cout<<"Pushed "<<n->data<<endl; } void pop() { node *n=new node; n=top; top=top->link; n->link=NULL; cout<<"Popped "<<n->data<<endl; delete n; } void print() { node *n=new node; n=top; while(n!=NULL) { cout<<n->data<<endl; n=n->link; } delete n; } }; int main() { node stack; stack.push(5); stack.push(7); stack.push(9); stack.pop(); stack.print(); } Any other suggestions welcome. I have also seen codes where there are two classes, where the second one has the top member. What about this? Thanks. :)

    Read the article

  • List of registered domain names

    - by Eric Chang
    Where can I find a list of domain names that I can download in a text file? I looked around and I found many sites with lists of expired domain names or domain names that will expire soon, but that's not what I need, I need a list of CURRENTLY REGISTERED domain names. The closest I found was this site (hxxp://www.list-of-domains.org/), but what I'm looking for ideally is just a plain list of registered domains and not some web links split across many pages full with ads and no text file. I know it's possible, after all how do these sites get the list of domains that they use? Where can I find such a list?

    Read the article

  • Passing List (Of ChildClass) as parameter to method expecting List (Of ParentClass)?

    - by Nicholas
    Hi, I have implemented inheritance for two parent classes called Table and Field. Each parent class has several child classes. In the Table parent class, I created a method that expects parameter List(Of Field). I get an error when trying to pass in parameter List(Of ChildField) to the method that expects a parameter of List(Of Field). The error message is as below: Value of type 'System.Collections.Generic.List(Of com.hlb.icisbatch.data.ChildField)' cannot be converted to 'System.Collections.Generic.List(Of com.hlb.icisbatch.data.Field)' My question, is it possible to pass in list of child class as parameter? If it is not a list then it works fine. But somehow it is not possible with lists? Below is sample class structure: Table Field | | ChildTable ChildField I have a method in the parent class: Public Class Table Public Sub New() End Sub Public Overridable Sub setFields(ByVal list As List(Of Field) 'Do work here' End Sub End Class and method in child class: Public Class ChildTable Public Sub New(ByVal list As List(Of ChildField) setFields(ChildField) End Sub End Class

    Read the article

  • Reworking my singly linked list

    - by Stradigos
    Hello everyone, thanks for taking the time to stop by my question. Below you will find my working SLL, but I want to make more use of C# and, instead of having two classes, SLL and Node, I want to use Node's constructors to do all the work (To where if you pass a string through the node, the constructor will chop it up into char nodes). The problem is, after an a few hours of tinkering, I'm not really getting anywhere... using System; using System.Collections.Generic; using System.Text; using System.IO; namespace PalindromeTester { class Program { static void Main(string[] args) { SLL mySLL = new SLL(); mySLL.add('a'); mySLL.add('b'); mySLL.add('c'); mySLL.add('d'); mySLL.add('e'); mySLL.add('f'); Console.Out.WriteLine("Node count = " + mySLL.count); mySLL.reverse(); mySLL.traverse(); Console.Out.WriteLine("\n The header is: " + mySLL.gethead); Console.In.ReadLine(); } class Node { private char letter; private Node next; public Node() { next = null; } public Node(char c) { this.data = c; } public Node(string s) { } public char data { get { return letter; } set { letter = value; } } public Node nextNode { get { return next; } set { next = value; } } } class SLL { private Node head; private int totalNode; public SLL() { head = null; totalNode = 0; } public void add(char s) { if (head == null) { head = new Node(); head.data = s; } else { Node temp; temp = new Node(); temp.data = s; temp.nextNode = head; head = temp; } totalNode++; } public int count { get { return totalNode; } } public char gethead { get { return head.data; } } public void traverse() { Node temp = head; while(temp != null) { Console.Write(temp.data + " "); temp = temp.nextNode; } } public void reverse() { Node q = null; Node p = this.head; while(p!=null) { Node r=p; p=p.nextNode; r.nextNode=q; q=r; } this.head = q; } } } } Here's what I have so far in trying to work it into Node's constructors: using System; using System.Collections.Generic; using System.Text; using System.IO; namespace PalindromeTester { class Program { static void Main(string[] args) { //Node myList = new Node(); //TextReader tr = new StreamReader("data.txt"); //string line; //while ((line = tr.ReadLine()) != null) //{ // Console.WriteLine(line); //} //tr.Close(); Node myNode = new Node("hello"); Console.Out.WriteLine(myNode.count); myNode.reverse(); myNode.traverse(); // Console.Out.WriteLine(myNode.gethead); Console.In.ReadLine(); } class Node { private char letter; private Node next; private Node head; private int totalNode; public Node() { head = null; totalNode = 0; } public Node(char c) { if (head == null) { head = new Node(); head.data = c; } else { Node temp; temp = new Node(); temp.data = c; temp.nextNode = head; head = temp; } totalNode++; } public Node(string s) { foreach (char x in s) { new Node(x); } } public char data { get { return letter; } set { letter = value; } } public Node nextNode { get { return next; } set { next = value; } } public void reverse() { Node q = null; Node p = this.head; while (p != null) { Node r = p; p = p.nextNode; r.nextNode = q; q = r; } this.head = q; } public void traverse() { Node temp = head; while (temp != null) { Console.Write(temp.data + " "); temp = temp.nextNode; } } public int count { get { return totalNode; } } } } } Ideally, the only constructors and methods I would be left with are Node(), Node(char c), Node(string s), Node reserve() and I'll be reworking traverse into a ToString overload. Any suggestions?

    Read the article

  • I'm new to C++. Please Help me with the Linked List (What functions to add)?

    - by Igal
    DEAR All; Hi, I'm just beginner to C++; Please help me to understand: What functions should be in the Linked list class ? I think there should be overloaded operators << and ; Please help me to improve the code (style, errors, etc,) Thanks for advance. Igal. Please review the small code for the integer List (enclosed MyNODE.h and ListDriver1.cpp); MyNODE.h // This is my first attempt to write linked list. Igal Spector, June 2010. #include <iostream.h> #include <assert.h> //Forward Declaration of the classes: class ListNode; class TheLinkedlist; // Definition of the node (WITH IMPLEMENTATION !!!, without test drive): class ListNode{ friend class TheLinkedlist; public: // constructor: ListNode(const int& value, ListNode *next= 0); // note: no destructor, as this handled by TheLinkedList class. // accessor: return data in the node. // int Show() const {return theData;} private: int theData; //the Data ListNode* theNext; //points to the next node in the list. }; //Implementations: //constructor: inline ListNode::ListNode(const int &value,ListNode *next) :theData(value),theNext(next){} //end of ListNode class, now for the LL class: class TheLinkedlist { public: //constructors: TheLinkedlist(); virtual ~TheLinkedlist(); // Accessors: void InsertAtFront(const &); void AppendAtBack(const &); // void InOrderInsert(const &); bool IsEmpty()const;//predicate function void Print() const; private: ListNode * Head; //pointer to first node ListNode * Tail; //pointer to last node. }; //Implementation: //Default constructor inline TheLinkedlist::TheLinkedlist():Head(0),Tail(0) {} //Destructor inline TheLinkedlist::~TheLinkedlist(){ if(!IsEmpty()){ //list is not empty cout<<"\n\tDestroying Nodes"<<endl; ListNode *currentPointer=Head, *tempPtr; while(currentPointer != 0){ //Delete remaining Nodes. tempPtr=currentPointer; cout<<"The node: "<<tempPtr->theData <<" is Destroyed."<<endl<<endl; currentPointer=currentPointer->theNext; delete tempPtr; } Head=Tail = 0; //don't forget this, as it may be checked one day. } } //Insert the Node to the beginning of the list: void TheLinkedlist::InsertAtFront(const int& value){ ListNode *newPtr = new ListNode(value,Head); assert(newPtr!=0); if(IsEmpty()) //list is empty Head = Tail = newPtr; else { //list is NOT empty newPtr->theNext = Head; Head = newPtr; } } //Insert the Node to the beginning of the list: void TheLinkedlist::AppendAtBack(const int& value){ ListNode *newPtr = new ListNode(value, NULL); assert(newPtr!=0); if(IsEmpty()) //list is empty Head = Tail = newPtr; else { //list is NOT empty Tail->theNext = newPtr; Tail = newPtr; } } //is the list empty? inline bool TheLinkedlist::IsEmpty() const { return (Head == 0); } // Display the contents of the list void TheLinkedlist::Print()const{ if ( IsEmpty() ){ cout << "\n\t The list is empty!!"<<endl; return; } ListNode *tempPTR = Head; cout<<"\n\t The List is: "; while ( tempPTR != 0 ){ cout<< tempPTR->theData <<" "; tempPTR = tempPTR->theNext; } cout<<endl<<endl; } ////////////////////////////////////// The test Driver: //Driver test for integer Linked List. #include <iostream.h> #include "MyNODE.h" // main Driver int main(){ cout<< "\n\t This is the test for integer LinkedList."<<endl; const int arraySize=11, ARRAY[arraySize]={44,77,88,99,11,2,22,204,50,58,12}; cout << "\n\tThe array is: "; //print the numbers. for (int i=0;i<arraySize; i++) cout<<ARRAY[i]<<", "; TheLinkedlist list; //declare the list for(int index=0;index<arraySize;index++) list.AppendAtBack( ARRAY[index] );//create the list cout<<endl<<endl; list.Print(); //print the list return 0; //end of the program. }

    Read the article

  • Global list in C/gtk+

    - by sterh
    Hello, I need in global list in my gtk+ application, i use for it GList: For example: I have structure: typedef struct _data { Glist list; }Data; I want to use one copy of the list in the whole program: I have a function bulid my list: gboolean build_list() { Data->list = g_list_append(mw->a, "First "); Data->list = g_list_append(mw->a, "Second "); Data->list = g_list_append(mw->a, "Third "); g_list_foreach(Data->list, (GFunc)printf, NULL); } After calling this function to display all items in the list. zbut when i try to make it in another function - for example: void foreach() { g_list_foreach(Data->list, (GFunc)printf, NULL); } I see error in gdb: *Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xb7335700 (LWP 5364)] 0xb765a7d7 in strchrnul () from /lib/i686/cmov/libc.so.6 * How can i create global list in my application? Thank you.

    Read the article

  • Designing a user-defined list to be stored in a relational database - Should I include user index?

    - by Zaemz
    By index, I mean, as the user creates the list, each item receives an integer index for its place in that particular list. Since there will be a table of ListItems, I'd prefer to avoid using the name "Index" for the field. Then I was thinking - should I even include the list index in the database? I figured I would because the list would be created in the same fashion every time, then. Or I could order the list for the user based on its actual primary key, since the list items are created in succession anyway... What should I do?

    Read the article

  • Sorting linked lists in Pascal

    - by user3712174
    I'm doing my final project for Informatics class and I can't get my sorting procedure to work. Have a look at my program, specifically the bolded part (some things are in Croatian. - if you need something translated, let me know): type pokazivac=^slog; slog=record prezime_ime:string[30]; redni_broj:string[2]; fakultet:string[50]; bodovi:integer; sljedeci:pokazivac; end; var pocetni, trenutni, prethodni:pokazivac; i:integer; procedure racunaj; var i,a,c:integer; b,d,e,f,g,h,j:real; begin write('Postotak bodova (u decimalnom zapisu) koje ucenik ostvaruje na temelju prosjeka ocjena - '); readln(e); e:=e*1000/4; write('Prosjek ocjena u prvom razredu : '); readln(f); f:=f/5*e; write('Prosjek ocjena u drugom razredu : '); readln(g); g:=g/5*e; write('Prosjek ocjena u trecem razredu : '); readln(h); h:=h/5*e; write('Prosjek ocjena u cetvrtom razredu : '); readln(j); j:=j/5*e; d:=f+g+h+j; write('Broj predmeta (ne racunajuci hrvatski jezik, strani jezik i matematiku) koju je ucenik/ca polagao na maturi - '); readln(a); write('Postotak rijesnosti ispita iz hrvatskog jezika te zatim maksimum bodova koje je ucenik/ca mogao ostvariti - '); readln(b); readln(c); d:=d+b*c; write('Postotak rijesnosti ispita iz stranog jezika te zatim maksimum bodova koje je ucenik/ca mogao ostvariti - '); readln(b); readln(c); d:=d+(b*c); write('Postotak rijesnosti ispita iz matematike te zatim maksimum bodova koje je ucenik/ca mogao ostvariti - '); readln(b); readln(c); d:=d+(b*c); for i:=1 to a do begin writeln('Postotak rijesnosti dodatnog predmeta te zatim maksimum bodova koje je ucenik/ca mogao ostvariti - '); readln(b); readln(c); d:=d+(b*c); end; d:=round(d); writeln('Vas broj bodova je: ', d:4:2); write('Za nastavak pritisnite ENTER..'); readln; end; procedure unos; begin new(trenutni); write('Redni broj ucenika - ');readln(trenutni^.redni_broj); write('Prezime i ime - ');readln(trenutni^.prezime_ime); write('Naziv fakultet - ');readln(trenutni^.fakultet); write('Bodovi - ');readln(trenutni^.bodovi); trenutni^.sljedeci:=pocetni; pocetni:=trenutni; end; procedure ispis; begin writeln(); writeln('Lista popisanih ucenika:'); writeln(); trenutni:=pocetni; while trenutni<>NIL do begin with trenutni^do begin writeln('IME: ',prezime_ime); writeln('FAKULTET: ',fakultet); writeln('BODOVI: ',bodovi); writeln(); end; trenutni:=trenutni^.sljedeci; end; writeln(); write('Za nastavak pritisnite ENTER..'); readln; end; procedure brisi; var s:string; begin trenutni:= pocetni; prethodni:=pocetni; write('Redni broj ucenika kojeg zelite izbrisati - '); readln(s); while trenutni<>NIL do begin if trenutni^.redni_broj=s then begin prethodni^.sljedeci:=trenutni^.sljedeci; dispose(trenutni); break; end; trenutni:=trenutni^.sljedeci; end; end; procedure izmjeni; var s:string; begin trenutni:=pocetni; write('Redni broj ucenika cije podatke zelite izmijeniti - '); readln(s); while trenutni<> NIL do begin if trenutni^.redni_broj=s then begin write(trenutni^.prezime_ime, ' - '); readln(trenutni^.prezime_ime); write(trenutni^.fakultet, ' - '); readln(trenutni^.fakultet); write(trenutni^.bodovi, ' - '); readln(trenutni^.bodovi); break; end; trenutni:=trenutni^.sljedeci; end; end; **procedure sortiraj; var t1,t2,t:pokazivac; begin t1:=pocetni; while t1 <> NIL do begin t2:=t1^.sljedeci; while t2<>NIL do if t2^.bodovi<t1^.bodovi then begin new(t); t^.redni_broj:=t1^.redni_broj; t^.prezime_ime:=t1^.prezime_ime; t^.fakultet:=t1^.fakultet; t^.bodovi:=t1^.bodovi; t1^.redni_broj:=t2^.redni_broj; t1^.prezime_ime:=t2^.prezime_ime; t1^.fakultet:=t2^.fakultet; t1^.bodovi:=t2^.bodovi; t2^.redni_broj:=t^.redni_broj; t2^.prezime_ime:=t^.prezime_ime; t2^.fakultet:=t^.fakultet; t2^.bodovi:=t^.bodovi; dispose(t); end; t2:=t2^.sljedeci; end; t1:=t1^.sljedeci; write('Za nastavak pritisnite ENTER..'); readln; end;** begin pocetni:=NIL; trenutni:=NIL; writeln('******************************************'); writeln('**********DOBRODOSLI U FAX-O-MAT**********'); writeln('******************************************'); repeat writeln('1 - Racunaj broj bodova'); writeln('2 - Dodaj ucenika'); writeln('3 - Brisi ucenika'); writeln('4 - Ispis liste'); writeln('5 - Izmjeni podatke'); writeln('6 - Sortiraj listu prema broju bodova'); writeln('0 - Kraj'); readln(i); case i of 1:racunaj; 2:unos; 3:brisi; 4:ispis; 5:izmjeni; 6:sortiraj; end; until i=0; end. Either it crashes with a fatal error, or when I press the number 6, nothing happens. The pointer keeps blinking and I can't enter any more numbers.

    Read the article

  • Adding items to the List at creation time in VB.Net

    - by Shaddix
    In c# I can initialize a List at creation time like var list = new List<String>() {"string1", "string2"}; is there a similar thing in VB.Net? Currently I can do it like Dim list As New List(Of String) list.Add("string1") list.Add("string2") list.Add("string3") but I want to avoid boring .Add lines

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >