# Tianke Youke

A Base for Secreting and Running at Night

0%

11月平均每日阅读43分钟，最高一天阅读4小时，总共21个小时。这意味着，这30天里，我大约有一整天的人生活在书里的世界。幸甚至哉！

In IT5003, I am studying data structures and algorithms. The language we learn with is Python. So I take notes about what I learned, and how to use them in Python. I struct my notes based on data structures, and all the ADTs that are implemented by the data structures are discussed within. I focus on their usage, key design, and sometimes problems. In the future maybe I will append all the implementation codes.

• ADT: Abstract data type, from the point of view of a user, defined by its behavior.
• Data Structure: from the point of view of an implementer, concrete representations of data.

# Linear Data Structures

## Searching and Sorting

### Searching algorithms

Search things in a list:

• if the list doesn't change frequently, better to sort first, then use binary-search everytime.

## Function

### Function Decorator

decorator equals to: foo = track(foo)

# Iterable/Sequences

Strings, ranges, lists and tuples.

“An iterable which supports efficient element access using integer indices via the __getitem__ special method and defines a __len__ method that returns the length of the sequence.”

• use one index to fetch item in a list, the index can't out of the range; but if use slice method, then you can do it out of the range, because the slice will autolly find the greediest indexs.

• assigning a list to another list, like a = b, makes a and b refers to the same list. And a list is mutable. So if we change a, then b will also be affected. It's called alias. Do avoid this.

• Tuple also has order. Just it's immutable.

• Fxxxk, Tuple and Set are different things! A set is like {1, 2, 3}, that is what I thought as not ordered and not duplicated. And a set has intersection() union() difference() symmetric_difference().

To delete items in a set:

• you can insert an interable in a list's slice, though they have different length!

• list() takes an iterable, and makes it a list;

str() shows you the whole object's look.

• range() is also an iterable. It can be slicing, and len()

• a, b = b, a: the b, a on the right firstly is packed into tuple: (b, a), then it is unpacked and individually assigned to each var on the left

## Short Circuit

• a and b evaluates to a if a is falsey, otherwise it evaluates to b
• a or b evaluates to a if a is truthy, otherwise it evaluates to b
• not a evaluates to True if a is falsey, otherwise it evaluates to False
• True is represented as 1, and False is represented as 0.

# Type System

## What are types:

• 意义的逻辑含义
• 一个契约，要求所有成员有共同的特性
• 所有值、变量都有type
• 所有对象object都有type
• 所有class、trait都type

value types & reference types

The Clustrmaps widget can show the visitors' map of my website. It is nice, but its 3D global version is buggy when put on the Hexo website. So I put its .js file locally, and modified several parts in it, to make it displayed normally on Hexo websites.

Maybe one day the .js file will be updated by Clustrmaps, and I'll need to revise it again. So I record what I did here.

1. Download the js file, put it here:/themes/next-new-version/source/js/clustrmaps.js, then the script label in the sidebar.swig is change as: <script type="text/javascript" id="clstr_globe" src="/js/clustrmaps.js?d=gWCOZyJlHF_Sc1eqXROD53yLLxxfC2y7Ytvw9JUfmFg"></script>. This way, I can modify codes in the .js file, or it would cause the following bugs.

2. The variable's name velocity is duplicated with that of Hexo😂😂. So I replaced all with velocityD in the .js file.

3. When the .js script is executed, the Hexo hasn't rendered the page yet, so the container of this widget still has width of 0. However, in the script, it fetches parent's width and sets it at that time! So it will disappear since its width is 0😅. To fix that, I changed the 302 line as:

The parent of parent of parent of the script label has normal width... This is funny but useful...