diff --git a/.idea/libraries/Go_SDK.xml b/.idea/libraries/Go_SDK.xml
new file mode 100644
index 0000000..6270938
--- /dev/null
+++ b/.idea/libraries/Go_SDK.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/queue.go b/queue.go
index 1084c29..0cecd52 100644
--- a/queue.go
+++ b/queue.go
@@ -14,13 +14,13 @@ const (
EVENT_TYPE EventType = 1
)
-type item struct {
- value interface{}
- priority int
+type Item struct {
+ Value interface{}
+ Priority int
}
type LoafleQueue struct {
- items []*item
+ items []*Item
queueType string
interval time.Duration
@@ -33,19 +33,19 @@ func (lq LoafleQueue) Len() int {
func (lq LoafleQueue) Less(i, j int) bool {
- return lq.items[i].priority < lq.items[j].priority
+ return lq.items[i].Priority < lq.items[j].Priority
}
func (lq LoafleQueue) Swap(i, j int) {
lq.items[i], lq.items[j] = lq.items[j], lq.items[i]
}
-func (lq *LoafleQueue) GetItems() []*item {
+func (lq *LoafleQueue) GetItems() []*Item {
time.Sleep(time.Second * lq.interval)
- resultItems := make([]*item, 0)
+ resultItems := make([]*Item, 0)
for lq.Len() > 0 {
- item := heap.Pop(lq).(*item)
+ item := heap.Pop(lq).(*Item)
resultItems = append(resultItems, item)
}
return resultItems
@@ -53,8 +53,8 @@ func (lq *LoafleQueue) GetItems() []*item {
func (lq *LoafleQueue) Push(i interface{}) {
n := len(lq.items)
- nItem := i.(*item)
- nItem.priority = n
+ nItem := i.(*Item)
+ nItem.Priority = n
lq.items = append(lq.items, nItem)
}
@@ -65,9 +65,9 @@ func (lq *LoafleQueue) Pop() interface{} {
lq.items = old[0 : n-1]
return nItem
}
-func (lq LoafleQueue) newItem(value interface{}) *item {
- return &item{
- value: value,
+func (lq LoafleQueue) newItem(value interface{}) *Item {
+ return &Item{
+ Value: value,
}
}
@@ -98,7 +98,7 @@ func (lq *LoafleQueue) Close() {
}
}
func NewQueue(eventType EventType, interval time.Duration) *LoafleQueue {
- items := make([]*item, 0)
+ items := make([]*Item, 0)
event := make(chan interface{}, 0)
lq := &LoafleQueue{