aboutsummaryrefslogtreecommitdiff
path: root/src/leveldb/util/histogram.h
blob: 1ef9f3c8abdfc50858be433110611086bb3c0da6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. See the AUTHORS file for names of contributors.

#ifndef STORAGE_LEVELDB_UTIL_HISTOGRAM_H_
#define STORAGE_LEVELDB_UTIL_HISTOGRAM_H_

#include <string>

namespace leveldb {

class Histogram {
 public:
  Histogram() { }
  ~Histogram() { }

  void Clear();
  void Add(double value);
  void Merge(const Histogram& other);

  std::string ToString() const;

 private:
  double min_;
  double max_;
  double num_;
  double sum_;
  double sum_squares_;

  enum { kNumBuckets = 154 };
  static const double kBucketLimit[kNumBuckets];
  double buckets_[kNumBuckets];

  double Median() const;
  double Percentile(double p) const;
  double Average() const;
  double StandardDeviation() const;
};

}  // namespace leveldb

#endif  // STORAGE_LEVELDB_UTIL_HISTOGRAM_H_
/span> import android.view.View; import android.view.View.OnKeyListener; import android.widget.EditText; public class MinetestTextEntry extends Activity { public AlertDialog mTextInputDialog; public EditText mTextInputWidget; private final int MultiLineTextInput = 1; private final int SingleLineTextInput = 2; private final int SingleLinePasswordInput = 3; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle b = getIntent().getExtras(); String acceptButton = b.getString("EnterButton"); String hint = b.getString("hint"); String current = b.getString("current"); int editType = b.getInt("editType"); AlertDialog.Builder builder = new AlertDialog.Builder(this); mTextInputWidget = new EditText(this); mTextInputWidget.setHint(hint); mTextInputWidget.setText(current); mTextInputWidget.setMinWidth(300); if (editType == SingleLinePasswordInput) { mTextInputWidget.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); } else { mTextInputWidget.setInputType(InputType.TYPE_CLASS_TEXT); } builder.setView(mTextInputWidget); if (editType == MultiLineTextInput) { builder.setPositiveButton(acceptButton, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { pushResult(mTextInputWidget.getText().toString()); } }); } builder.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { cancelDialog(); } }); mTextInputWidget.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View view, int KeyCode, KeyEvent event) { if ( KeyCode == KeyEvent.KEYCODE_ENTER){ pushResult(mTextInputWidget.getText().toString()); return true; } return false; } }); mTextInputDialog = builder.create(); mTextInputDialog.show(); } public void pushResult(String text) { Intent resultData = new Intent(); resultData.putExtra("text", text); setResult(Activity.RESULT_OK,resultData); mTextInputDialog.dismiss(); finish(); } public void cancelDialog() { setResult(Activity.RESULT_CANCELED); mTextInputDialog.dismiss(); finish(); } }