面試總結之 各種定義題 英文口語

Singleton算法

private static Singleton firstInstance = null;
    public static Singleton getInstance() {
        if(firstInstance == null) {
            
            // This is here to test what happens if threads try
            // to create instances of this class
            
            if(firstThread){
            
                firstThread = false;
                
                try {
                    Thread.currentThread();
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                
                    e.printStackTrace();
                }
            }
            
            // Here we just use synchronized when the first object
            // is created
            
            synchronized(Singleton.class){ 
            
                if(firstInstance == null) {
                    // If the instance isn't needed it isn't created
                    // This is known as lazy instantiation
            
                    firstInstance = new Singleton();
            
                    // Shuffle the letters in the list
                    Collections.shuffle(firstInstance.letterList);
                    
                }
            
            }
            
        }
        
        // Under either circumstance this returns the instance
        
        return firstInstance;
    }
In software engineering, the singleton pattern is a design pattern that restricts
 the instantiation of a class to one object. This is useful when exactly one object
  is needed to coordinate actions across the system. The concept is sometimes generalized
   to systems that operate more efficiently when only one object exists, or that restrict
    the instantiation to a certain number of objects. The term comes from the mathematical
     concept of a singleton.

 

 

Factory 編程

// This is a factory thats only job is creating ships
// By encapsulating ship creation, we only have one
// place to make modifications

public class ENEMYSHIPFACTORY{
    
    // This could be used as a static method if we
    // are willing to give up subclassing it
    
    public ENEMYSHIP makeEnemyShip(String newShipType){
        
        //ENEMYSHIP newShip = null;
        
        if (newShipType.equals("U")){
            
            return new UFOENEMYSHIP();
            
        } else 
        
        if (newShipType.equals("R")){
            
            return new ROCKETENEMYSHIP();
            
        } else 
        
        if (newShipType.equals("B")){
            
            return new BIGUFOENEMYSHIP();
            
        } else return null;
        
    }
    
}
When a method returns one of several possible classes that share a commom super class

the factory pattern allows you to create objects without specifying the exact class of 
object that will be created.

 

 

 a virtual function or virtual method is a function or method whose behavior can be overridden within an inheriting class by a function with the same signature. This concept is a very important part of the polymorphism portion of object-oriented programming (OOP).數組

 

"A pure virtual function or pure virtual method is a virtual function that is required to be implemented by a derived class that is not abstract" - Wikipedia瀏覽器

So, the virtual function can be overriden and the pure virtual must be implemented.緩存

 

As the name inheritance suggests an object is able to inherit characteristics from another object. In more concrete terms, an object is able to pass on its state and behaviors to its children. For inheritance to work the objects need to have characteristics in common with each other.服務器

 

static:網絡

 

static variables are shared by the entire class, not a specific instance (unlike normal member variables)
static methods are also shared by the entire class

static can be used around a block of code in a class to specify code that runs when the virtual machine is first started up, before instances of the class are created.

 

 

(計算機編程英語詞彙)算法經常使用術語中英對照Data Structures 基本數據結構Dictionaries 字典Priority Queues 堆        Graph Data Structures 圖Set Data Structures 集合Kd-Trees 線段樹Numerical Problems 數值問題Solving Linear Equations 線性方程組Bandwidth Reduction 帶寬壓縮Matrix Multiplication 矩陣乘法Determinants and Permanents 行列式Constrained and Unconstrained Optimization 最值問題Linear Programming 線性規劃Random Number Generation 隨機數生成Factoring and Primality Testing 因子分解/質數斷定Arbitrary Precision Arithmetic 高精度計算Knapsack Problem 揹包問題Discrete Fourier Transform 離散Fourier 變換Combinatorial Problems 組合問題Sorting 排序Searching 查找Median and Selection 中位數Generating Permutations 排列生成Generating Subsets 子集生成Generating Partitions 劃分生成Generating Graphs 圖的生成Calendrical Calculations 日期Job Scheduling 工程安排Satisfiability 可知足性Graph Problems -- polynomial 圖論-多項式算法Connected Components 連通分支Topological Sorting 拓撲排序Minimum Spanning Tree 最小生成樹Shortest Path 最短路徑Transitive Closure and Reduction 傳遞閉包Matching 匹配Eulerian Cycle / Chinese Postman Euler 迴路/中國郵路Edge and Vertex Connectivity 割邊/割點Network Flow 網絡流Drawing Graphs Nicely 圖的描繪Drawing Trees 樹的描繪Planarity Detection and Embedding 平面性檢測和嵌入Graph Problems -- hard 圖論-NP 問題Clique 最大團Independent Set 獨立集Vertex Cover 點覆蓋Traveling Salesman Problem 旅行商問題Hamiltonian Cycle Hamilton 迴路Graph Partition 圖的劃分Vertex Coloring 點染色Edge Coloring 邊染色Graph Isomorphism 同構Steiner Tree Steiner 樹Feedback Edge/Vertex Set 最大無環子圖Computational Geometry 計算幾何Convex Hull 凸包Triangulation 三角剖分Voronoi Diagrams Voronoi 圖Nearest Neighbor Search 最近點對查詢Range Search 範圍查詢Point Location 位置查詢Intersection Detection 碰撞測試Bin Packing 裝箱問題Medial-Axis Transformation 中軸變換Polygon Partitioning 多邊形分割Simplifying Polygons 多邊形化簡Shape Similarity 類似多邊形Motion Planning 運動規劃Maintaining Line Arrangements 平面分割Minkowski Sum Minkowski 和Set and String Problems 集合與串的問題Set Cover 集合覆蓋Set Packing 集合配置String Matching 模式匹配Approximate String Matching 模糊匹配Text Compression 壓縮Cryptography 密碼Finite State Machine Minimization 有窮自動機簡化Longest Common Substring 最長公共子串Shortest Common Superstring 最短公共父串DP——Dynamic Programming——動態規劃recursion ——遞歸編程詞彙A2A integration A2A 整合abstract 抽象的abstract base class (ABC)抽象基類abstract class 抽象類abstraction 抽象、抽象物、抽象性access 存取、訪問access level 訪問級別access function 訪問函數account 帳戶action 動做activate 激活active 活動的actual parameter 實參adapter 適配器add-in 插件address 地址address space 地址空間address-of operator 取地址操做符ADL (argument-dependent lookup)ADO(ActiveX Data Object)ActiveX 數據對象advanced 高級的aggregation 聚合、彙集algorithm 算法alias 別名align 排列、對齊allocate 分配、配置allocator 分配器、配置器angle bracket 尖括號annotation 註解、評註API (Application Programming Interface)應用(程序)編程接口app domain (application domain)應用域application 應用、應用程序application framework 應用程序框架appearance 外觀append 附加architecture 架構、體系結構archive file 歸檔文件、存檔文件argument 引數(傳給函式的值)。參見parameterarray 數組arrow operator 箭頭操做符ASP(Active Server Page)活動服務器頁面ASP.NET worker process ASP.NET 工做者進程assembly 裝配件、配件assembly language 彙編語言assembly manifest 裝配件清單assert(ion)斷言assign 賦值assignment 賦值、分配assignment operator 賦值操做符associated 相關的、相關聯的associative container 關聯式容器(對應sequential container)asynchronous 異步的atomic 原子的atomic operation 原子操做attribute 特性、屬性authentication service 驗證服務authorization 受權audio 音頻A.I. 人工智能B2B integration B2B 整合、B2B 集成(business-to-business integration)background 背景、後臺(進程)backward compatible 向後兼容、向下兼容backup 備份backup device 備份設備backup file 備份文件bandwidth 帶寬base class 基類base type 基類型batch 批處理BCL (base class library)基類庫binary 二進制binary search 二分查找binary tree 二叉樹binary function 雙參函數binary large object 二進制大對象binary operator 二元操做符binding 綁定bit 位bitmap 位圖bitwise 按位...bitwise copy 爲單元進行復制;位元逐一複製,按位拷bitwise operation 按位運算block 塊、區塊、語句塊bookkeeping 簿記boolean 布林值(真假值,true 或false)border 邊框bounds checking 邊界檢查boxing 裝箱、裝箱轉換brace (curly brace)大括號、花括號bracket (square brakcet)中括號、方括號breakpoint 斷點browser applications 瀏覽器應用(程序)browser-accessible application 可經由瀏覽器訪問的應用程序build 編連(專指編譯和鏈接built-in 內建、內置bus 總線business 業務、商務(看場合)business Logic 業務邏輯business rules 業務規則buttons 按鈕bug 臭蟲by/through 經過byte 位元組(由8 bits 組成)cache 高速緩存calendar 日曆call 調用callback 回調call-level interface (CLI)調用級接口(CLI)call operator 調用操做符candidate key 候選鍵(for database)cascading delete 級聯刪除(for database)cascading update 級聯更新(for database)casting 轉型、造型轉換catalog 目錄chain 鏈(function calls)character 字符character format 字符格式character set 字符集CHECK constraints CHECK 約束(for database)checkpoint 檢查點(for database)check box 複選框check button 複選按鈕child class 子類CIL (common intermediate language)通用中間語言、通用中介語言class 類class declaration 類聲明class definition 類定義class derivation list 類繼承列表class factory 類廠class hierarchy 類層次結構class library 類庫class loader 類裝載器class template 類模板class template partial specializations 類模板部分特化class template specializations 類模板特化classification 分類clause 子句client application 客戶端應用程序client cursor 客戶端遊標(for database)code page 代碼頁cleanup 清理、清除CLI (Common Language Infrastructure) 通用語言基礎設施client 客戶、客戶端
相關文章
相關標籤/搜索