The following web page is supplement to the main project document, available as a PDF .
We will use Autolab, but the specific scripts we will want you to run to create your submission do not yet exist. Hang on for a bit, but later:
No. The back-end store is simply an in-memory hashtable (a Go map).
Remember, it is not a good design to store a user's tribbles in a list. Instead, the list should contain only tribble ids (that you have to define). Tribbles should be stored as separate objects in the hashtable, with the tribble id as the key. Get and Put should therefore be used for tribbles, and AddToList and RemoveFromList for manipulating lists (i.e., lists of tribble ids, and lists of "followees"). Also, we think you'll find the atomicity provided by the List functions quite useful.
100 in total.
No. The back-end must store all tribbles ever posted.
It is sufficient to encode only the values (before adding them to the hashtable).
Coming soon
We strongly recommend that you use git to do so. See the 15-410 Git Quickstart for help. More information coming on this soon.
As you did in Project 1, use the package json. Documentation on specific usage is available at: http://golang.org/pkg/json/ and more information on JSON in general is available at http://www.json.org/.
As the saying goes, there is more than one way to skin this cat.
The map data structure in Go allows you to associate values of any type (that are able to be compared with the == operator), with any other type.
Initialize a map as a type with:
type SomeMap map[int]string myMap := make(SomeMap)Add a value to the map with:
myMap[1] = "Some String"You can retrieve this value, along with a boolean telling you if the key is present in the map, with:
value, present := myMap[1]Remember, maps can store any type as the value, not just strings.
Utilize the "sync" package to apply a mutex lock to the data structure.
One way this can be implemented is to declare the map type as a struct with two fields - one for the map itself, and one for the lock.
import "sync" type SomeMap struct { theData map[int]string theLock sync.Mutex }You then might add a convenience function to initialize your SomeMap struct, such as:
func NewSomeMap() *SomeMap { return &SomeMap { theData: make(map[int]string) } }(noting that the default for a lock is to have it be initialized, but unlocked)
Last updated: Tue Oct 09 21:47:20 -0400 2012 [validate xhtml]