84th: Scala's list and listbuffer design implementation thinking

Source: Internet
Author: User

To learn about the list and Listbuffer in Scala today.

Many operations within the Scala list are listbuffer, because changing the elements listbuffer very efficient,
TL is var type, but he belongs to the Scala package and the child package, we seem to be mutable, but because of the limitations of the package we do not see.
List append element, if TL front without private[scala], you can change in addition to the first element, all other elements built by the list,
Because we have the same TL, append different elements, construct different lists, you can share the case class::,
The list of operation Tails, pointing to the same data structure.
If it is developed completely externally, because the TL element is not controllable, it is troublesome to share.
Listbuffer has start,last0, the element content as start, appended from the back,
We should not only ensure the efficiency of the elements, but also the external is the function of the style, so with Private[scala] Var
Listbuffer is the content of the Scala sub-package, so you can access and modify the list, while the external is private, other objects
It is not possible to modify the list so that it can be both variable and functional in style.

Share more of the Scala resources:

Baidu Cloud Disk: http://pan.baidu.com/s/1gd7133t

Micro Cloud Disk: http://share.weiyun.com/047efd6cc76d6c0cb21605cfaa88c416

360 Cloud Disk: Http://yunpan.cn/cQN9gvcKXe26M (extract code: 13CD)

Information from DT Big Data Dream Factory public account: Dt_spark

Follow the account for more information about Scala learning

84th: Scala's list and listbuffer design implementation thinking

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.