Java and C # Control Learning Series - Data Structure

xiaoxiao2021-03-06  64

I personally feel: Through the implementation of practice data structure in different languages, you can quickly familiarize yourself with the new language language to learn about each other. Nested classes in the Java class can be a field in the class, and you can directly access other fields directly in the nested class, and the Field in the nested class is also exposed outside! And in the C # love is different from Java, and there is no C Friend keyword! How to do? I saw a website name "Data Structures and Algorith WITH OBJECT-Oriented Design Patterns", and the source code implemented by C , Java, C # data structure, see the definition of others: Take LinkedList as an example: //// This file contains the C code from Program 4.9 of // "Data Structures and Algorithms // with Object-Oriented Design Patterns in C " // by Bruno R. Preiss.//// Copyright (c) 1998 by Bruno R. Preiss , P.Eng. All rights reserved./// http://www.pads.uwaterloo.ca/bruno.preiss/books/opus4/Programs/pgm04_09.cpp/Template // Do not declare in advance, the C compiler will not find LinkedListClass LinkedList; // and C # does not have to be in this!

Template Class Listelement {T Datum; Listerlement * Next;

Listelement (T Const &, Listelement *); Public: T Const & Datum () Const; Listelement Const * Next () Const;

Friend LinkedList ; // *};

Template Class LinkedList {Listelement * Head; Listelement * TAIL; Public: LinkedList (); ~ LinkedList ();

LinkedList (LinkedList Const &); LinkedList & Operator = (LinkedList Const &);

Listelement const * tail () const; ipsempty () const; t const & number () const; t..

Void Prepend (T Const &); Void Extract (T Const &); Void Purge (); Void InsertAfter (Listelement Const *, T Const &); Void InsertBefore (Listelement const *, T const &;}; //// this file contains the java code from program and algorithms // with object-orient design pattern in java "// By Bruno R. preiss.///// Copyright (c) 1998 by Bruno R. preiss, p.eng. All rights reserved./// http://www.pads.uwaterloo.ca/bruno.preiss/books/opus5/Programs/pgm04_13.txt// PUBLIC CLASS LinkedList {Protected Element Head; Protected Element TAIL;

Public final class element // Nested, using private modifications should also be {Object Datum; ELECT NEXT;

ELEMENT (Object Datum, Element Next) {this.datum = DATUM; this.next = next;}

Public Object getdatum () {return Datum;}

Public element getnext () {return nEXT;} // ...} // ...}

//// this file contains the c # code from program 4.12 of // "Data Structures and algorithms //" b j / c c # # c # Bruno R. Preiss, P.Eng. All rights reserved.// Note: The history of C # has been a few years! Haha! // http://www.pads.uwaterloo.ca/bruno.preiss/books/opus6/Programs/pgm04_12.txt/public class link; protected element head; protected element tail;

Public Sealed Class Element // Keyword Sealed is similar to Java's Final, but final features! {INTERNAL LinkedList List; // Keyword INTERNAL INTER OBJECT DATUM; Internal Element Next

INTERNAL ELEMENT (LINKEDLIST LIST) {this.list = list; this.datum = DATUM; THIS.

Public Object Datum;}} public element next {get {return next;}} // ...} // ...}

URL: http://www.brpreiss.com/ There is an online document on its website, as well as a relationship between individual classes and interfaces. I have a little effort to take some effort, I am working hard! I think we can also learn how to organize class, interface, and language. You can also contact Pattern's thoughts when you learn the data structure, why not! If you are familiar with the data structure, you can download the source code directly, and when you review!

转载请注明原文地址:https://www.9cbs.com/read-87194.html

New Post(0)