design

package
v0.0.0-...-7253c86 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 12, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	// contains filtered or unexported fields
}

type LRUCache

type LRUCache struct {
	// contains filtered or unexported fields
}

func Constructor

func Constructor(capacity int) LRUCache

func (*LRUCache) Get

func (this *LRUCache) Get(key int) int

func (*LRUCache) Put

func (this *LRUCache) Put(key int, value int)

type Tweet

type Tweet struct {
	ID        int
	Timestamp int
}

Tweet represents a tweet with its ID and timestamp.

type Twitter

type Twitter struct {
	// contains filtered or unexported fields
}

Twitter represents the Twitter service.

func TwitterConstructor

func TwitterConstructor() Twitter

Constructor initializes a new Twitter instance.

func (*Twitter) Follow

func (this *Twitter) Follow(followerId int, followeeId int)

Follow adds followeeId to the followerId's following list.

func (*Twitter) GetNewsFeed

func (this *Twitter) GetNewsFeed(userId int) []int

GetNewsFeed returns the 10 most recent tweetIds in the user's news feed.

func (*Twitter) PostTweet

func (this *Twitter) PostTweet(userId int, tweetId int)

PostTweet adds a tweet to the user's tweet list and records its timestamp.

func (*Twitter) Unfollow

func (this *Twitter) Unfollow(followerId int, followeeId int)

Unfollow removes followeeId from the followerId's following list.

type TwitterMaxHeap

type TwitterMaxHeap []Tweet

TwitterMaxHeap is a priority queue (max heap) for storing tweets by timestamp.

func (TwitterMaxHeap) Len

func (h TwitterMaxHeap) Len() int

func (TwitterMaxHeap) Less

func (h TwitterMaxHeap) Less(i, j int) bool

func (*TwitterMaxHeap) Pop

func (h *TwitterMaxHeap) Pop() interface{}

func (*TwitterMaxHeap) Push

func (h *TwitterMaxHeap) Push(x interface{})

func (TwitterMaxHeap) Swap

func (h TwitterMaxHeap) Swap(i, j int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL