--
You received this message because you are subscribed to the Google Groups "cs410pku" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cs410pku+u...@googlegroups.com.
To post to this group, send email to cs41...@googlegroups.com.
Visit this group at http://groups.google.com/group/cs410pku?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
我认为用map<string, Posting*>,还是vector<Posting*>,前者Posting中可以不含有string word变量,后者必须含有。无论使用map还是vector,都是用string这个变长字符串类型来存储word,一个string是由一个地址指针以及该指针指向的内容构成,这个地址指针可以看成书中图5-4的词项指针,内容可以看成图5-4中超长字符串的一小部分。所以相对于定长数组存储词典,已经进行了压缩。
在32位系统中地址指针是4B,64位系统则是8B,若自己实现一种指针的话,按照书中计算只需3B。但是否节省空间跟具体实现相关,如果该指针本身还需要开辟空间来存储,比如char p[3],那么反而多了3B的开销。