ARST高效學(xué)習(xí)第一周(2020/03/09-03/15)

說明

ARTS 是陳浩發(fā)起的高效學(xué)習(xí)計(jì)劃,包括四個部分:Algorithm/Review/Tip/Share
什么是ARST打卡計(jì)劃?

Algorithm


題目:反轉(zhuǎn)一個單鏈表。
code:

/*
 * @lc app=leetcode.cn id=206 lang=cpp
 *
 * [206] 反轉(zhuǎn)鏈表
 */

// @lc code=start
/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode(int x) : val(x), next(NULL) {}
 * };
 */
class Solution {
 public:
  ListNode* reverseList(ListNode* head) {
    if (head == nullptr) {
      return head;
    }
    // store reverlist;
    ListNode* list = new ListNode(head->val);
    ListNode* temp = head;
    while (temp->next != nullptr) {
      temp = temp->next;
      ListNode* oldHead = list;
      list = new ListNode(temp->val);
      list->next = oldHead;
      oldHead = nullptr;
    }
    temp = nullptr;
    return list;
  }
};

Review


本周看了一篇Android MVVM的架構(gòu)文章。
ViewModel 和 LiveData:模式 + 反模式

Android MVVM架構(gòu)

本質(zhì)上所有的架構(gòu)都是一個思想,分類數(shù)據(jù),UI和業(yè)務(wù)邏輯。
文章中列出了幾條原則:

  • Don’t let ViewModels (and Presenters) know about Android framework classes
  • Keep the logic in Activities and Fragments to a minimum
  • Avoid references to Views in ViewModels.
  • Instead of pushing data to the UI, let the UI observe changes to it.
  • Consider edge cases, leaks and how long-running operations can affect the instances in your architecture.

Tip


C++中為什么有拷貝和移動構(gòu)造函數(shù),JAVA中為什么沒有?
因?yàn)镃++對象中拷貝的對象(包含內(nèi)存地址),所以開銷比較大,因此移動構(gòu)造函數(shù),就是為了降低開銷而出現(xiàn)的,而Java中只拷貝了引用,開銷小。

Share


接下來打算寫車載系統(tǒng)的文章,本周正在構(gòu)思中...

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容